Affiliates plugin with woocommerce

I currently use woocommerce to run my online store.

Is it possible to track sales from an affiliate using the affiliate plugin?

    JD
    • 27
    • #4,478

    Thanks.

    I hadn't looked for an alternate plugin. I was hoping to stick with wpmu.

    I guess I'll see if I can get it to work, use an alternate plugin or migrate to MarketPress.

    Thanks again!

    JD
    • 27
    • #4,478

    I looked at the various affiliate plugins. I'm really trying to get this one to work with woocommerce.

    I've added a woocommerce addon with the following code...

    function affiliate_wc_record_affiliate( $order_id ) {
    
    	// Call the affiliate action
    	do_action( 'affiliate_signup' );
    
    	if(defined( 'AFFILIATEID' )) {
    		// We found an affiliate that referred this order creation - so add a meta to the order recording it
    		if (function_exists('update_post_meta')) {
    			update_post_meta( $order_id, '_affiliate_id', AFFILIATEID );
    		}
    	}
    
    }
    add_action('woocommerce_checkout_update_order_meta', 'affiliate_wc_record_affiliate');

    It definitely calls the function at the right point, just as the user clicks to pay at the checkout page.

    The debug addon is telling me that there has been a referral as well.

    It's just not recording the referral in the post meta.

    Any suggestions?

    JD
    • 27
    • #4,478

    Any chance someone could please help me resolve this?!

    Once this is fixed, the Affiliates plugin will work with woocommerce and you can consider adding this to the next release :)

    Please help!

    puccino
    • Elite
    • 551
    • #154

    Hi, do you have any news on your woocommerce integration ?
    I'm searching this too.

    JD
    • 27
    • #4,478

    Hi Puccino

    Unfortunately no one has responded to my query so I haven't been able to progress this.

    The lastest code I am using is below.

    I have done multiple tests on this and it updates the correct order.

    The only problem is, is that the do_action( 'affiliate_signup' ) does not return the AFFILIATEID as it should. This is part of the actual plugin so I don't understand why it's not working.

    I was hoping that someone from wpmudev would assist. I'm still waiting.

    JD

    function affiliate_wc_record_affiliate( $order_id ) {
    	global $woocommerce;
    
    	// Call the affiliate action
    	do_action( 'affiliate_signup' );
    
    	if(defined( 'AFFILIATEID' )) {
    		// We found an affiliate that referred this order creation - so add a meta to the order recording it
    		if (function_exists('update_post_meta')) {
    			update_post_meta( $order_id, '_affiliate_id', AFFILIATEID );
    		}
    	}
    
    	//if ($this->debug=='yes') $this->log->add( 'affiliate', 'Affiliate record.' );
    
    }
    add_action('woocommerce_checkout_update_order_meta', 'affiliate_wc_record_affiliate');
    Mason

    Hiya,

    Just re-opening this for you and pinging our lead developer @Barry so he can assist here.

    Thanks!

    Barry

    Have you activated the affiliate debug addon so that you can see what the plugin is doing on the front end of your site?

    JD
    • 27
    • #4,478

    Hi Barry

    Sorry. I didn't realise you had responded.

    Yes. I activated the affiliate debug. The debug suggests the affiliate plugin is working as expected and did recorded the affiliate referral (see screenshot).

    Also, if I was to now add items, and proceed to checkout this function is also called at the right time. Just as the order is created a new the post_meta attribute of _affiliate_id is added; however the actual affiliate id recorderd is the variable name "AFFILIATEID".

    After a big of testing, I think the do_action( 'affiliate_signup' ) is triggered however the AFFILIATEID is not being defined.

    Any thoughts?

    JD

    Barry

    If the debug addon is showing the correct cookie has been created all the way up to the purchase page then that is very strange :/ does the domain change at any point during that last step? Or is you code called outside the browser (e.g. by cron or ipn, etc which wouldn't then be able to get the cookie details) ?

    Have to admit, at the moment those are the only two things I can think of, but will keep racking my brain.

    Mason

    Hiya @puccino, I think we're still awaiting a little more feedback from @JD on this one. Are you having any issues?

    Thanks!

    greg_mcewan_marriott
    • Monthly
    • 318
    • #298

    @ JD, would it be possible to share your woocommerce add on? I would like to see if i can hook this into a ML Affiliate system I am working on?

    rahul286
    • 39
    • #3,083

    I am also interested in this. Count me in! :-)

    puccino
    • Elite
    • 551
    • #154

    Can a dev tell us if you are working on this ?
    I don't want to buy a plugin from another site....

    Timothy

    I'm not sure if @Barry is currently working on this or not or what the plans are.

    So I've pinged him for more information.

    Thanks.

    Barry

    As I have zero experience with woocommerce this is quite low down on my todo list. My priorities with affiliate integration at the moment are to complete the Pro-sites and MarketPress integrations and to get add-ons completed for the other WPMUDEV plugins (classifieds, appointments, events, etc.).

    If anyone knows more about the woocommerce code / hooks and filters than me (not difficult as I know nothing about them) then please do post and I'll be happy to direct on the affiliate side of things.

    Fadie Hany
    • 1
    • #29,640

    It's been a long time since anyone has responded here but if anyone has figured this integration out it would be greatly appreciated. Thank you!

Join 370578 happy members

Get access to our entire collection of epic plugins, astonishing themes & genius support

Become a member