Support » Plugin: PW WooCommerce Affiliates » How to replace the affiliate link with the affiliate code on the user side ?

  • Resolved worldless

    (@worldless)


    Hello. I’d like to have the affiliate code displayed on the user side instead of the link. is there any hook to replace it ?

    I ran into a similar thread and I tried to remove get_site_url():
    https://wordpress.org/support/topic/how-to-change-the-default-affiliate-url/

    function custom_pw_affiliates_shop_page_url( $url ) {
        // Change this to suit your needs:
        return get_site_url();
    }
    add_filter( 'pw_affiliates_shop_page_url', 'custom_pw_affiliates_shop_page_url' );

    but this is what I got instead: affiliate=UserCode?

Viewing 4 replies - 16 through 19 (of 19 total)
  • Plugin Author pimwick

    (@pimwick)

    And just in case, here is the body of the article that I linked to in my response:

    We use the WordPress template system to make it possible for easy customization. To override the affiliate report, copy this file:

    /wp-content/plugins/pw-woocommerce-affiliates/templates/woocommerce/pw-affiliates-report.php

    To here (you may need to create the subfolders if they do not exist in your theme folder):

    /wp-content/themes/<your-active-theme>/woocommerce/pw-affiliates-report.php

    Once the file is in your theme folder, open it up in a text editor and make any changes.

    Thread Starter worldless

    (@worldless)

    First of all, I finally figured it out with your help. you didn’t help me 100% but without your help I wouldn’t have made it. excellent! we’re getting somewhere. I’m going to raise my star rating only because you tried to outsmart me 🙂

    I think that I (finally) understand! When an affiliate logs in and goes to the Affiliate Dashboard from the “My Account” page, there is an “Affiliate URL” displayed at the top. You want this to instead be the affiliate’s code and not a URL.

    🙂

    This hook is used inside the pwwa_affiliate_url() function which (as the name implies) returns a URL and it is used throughout the plugin, including the Admin dashboard.

    Wrong! this hook has no effect on the back-end! like I said in the first post I already tried removing get_site_url() and it only removed the link for the affiliate.

    Instead of trying to use that hook, you can override the template for the frontend Affiliate Report. That way you can also change “Affiliate URL” title header to be “Affiliate Code” as well.

    title header?! I really love the way you’re pulling my leg 🙂 so let me just quote what you understood earlier:
    >>> Pimwick: I think that I (finally) understand! when an affiliate logs in and goes to the Affiliate Dashboard from the “My Account” page, there is an “Affiliate URL” displayed at the top. You want this to instead be the affiliate’s code and not a URL<<<<

    So changing “Affiliate URL” to “Affiliate Code” in pw-affiliates-report.php = Changing Title !!

    Like I said I figured it out. the answer is somewhere right below the “Affiliate URL”. so let’s just keep it as a secret since you like it that way.

    I guess you win 😉

    Hooray ! 🙂

    Plugin Author pimwick

    (@pimwick)

    First of all, I finally figured it out with your help.

    Glad to hear you found the solution.

    Wrong! this hook has no effect on the back-end!

    When you change this hook, log into your WordPress admin area and go to Pimwick Plugins -> PW Affiliates. Look at the “URL” column for each Affiliate and you will see that it has changed the URL in the back-end.

    Like I said I figured it out. the answer is somewhere right below the “Affiliate URL”. so let’s just keep it as a secret since you like it that way.

    Once again I made an assumption and I should have been more explicit. I felt it was obvious what to change once you had gotten this far. For the sake of completeness, here is the step by step instructions (highlighting the part that I felt was obvious):

    1. Override the template using the instructions provided in my last comment.
    2. Locate the href for the Affiliate URL (line 57 in the template file). It looks like this:

    <div class="pwwa-title"><?php _e( 'Affiliate URL', 'pw-woocommerce-affiliates' ); ?></div>
    <a href="<?php echo $affiliate->get_url(); ?>" class="pwwa-copy-url" title="<?php _e( 'Copy URL to Clipboard', 'pw-woocommerce-affiliates' ); ?>"><?php echo $affiliate->get_url(); ?></a>

    You can change the HTML to just be the code by replacing that line with this instead:

    <div class="pwwa-title">Affiliate Code</div>
    <?php echo esc_html( $affiliate->get_code() ); ?>

    3. Save the file. This change will output the code instead of a full URL.

    Let me know if you have any questions!

    Thread Starter worldless

    (@worldless)

    @pimwick Thanks for your help

Viewing 4 replies - 16 through 19 (of 19 total)
  • You must be logged in to reply to this topic.