Home Integration Methods WooCommerce (WordPress module)

WooCommerce (WordPress module)

This integration with WooCommerce is really easy as you can connect the two using the WordPress plugin. When installed, configure it to define what do you want to track and how.

You can track per product commissions, order ID and coupons.


If you want to (or have to) integrate WooCommerce manually, here's a guide.
1
Order tracking
To track whole order, use the following code. Edit file wp-content/plugins/woocommerce/templates/checkout/thankyou.php and place the code below line:
<?php do_action( 'woocommerce_thankyou', $order->id ); ?>
Note:
In case you use a custom theme for WooCommerce and the thankyou.php file is located there as well (/themes/your_custom_theme/woocommerce/checkout/thankyou.php), you have to integrate it instead of the default one.

If you want more detailed tracking, follow the next step instead of this one.
If you wish to take use of Lifetime Commissions plugin then right above 
PostAffTracker.register();

add this:
sale.setData1('<?php echo $order->billing_email; ?>');
or this
sale.setData1('<?php echo $order->user_id; ?>');

2
Per product integration
If you want to track commissions per product, use this code instead the one form step 1. You have to place it to the same file, at the same place:
wp-content/plugins/woocommerce/templates/checkout/thankyou.php
right below this line:
<?php do_action( 'woocommerce_thankyou', $order->id ); ?>
Save your changes. That's it, your shop has been integrated.
If you want to take use of Lifetime Commissions plugin, then right below
echo "sale".$i.".setCoupon('".$couponCode."');";

add this:
echo "sale".$i.".setData1('".$order->billing_email."');";
or this:
echo "sale".$i.".setData1('".$order->user_id."');";
3
Integration of PayPal module in WooCommerce - part 1
Find and edit the following file:
  • for WooCommerce 2.2.11 and lower: woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php

  • for WooCommerce 2.3.3 and higher: woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php

You can edit the plugin files either using the Plugin editor in WordPress or you can access the files of your WP installation via FTP.

In the above mentioned file find the function get_paypal_args() function and within it find a line with 'return => ' and a line with 'notify_url =>' string. Change the found lines by adding a special code (bold and underlined):

'return' => esc_url( add_query_arg( 'utm_nooverride', '1', $this->get_return_url( $order ) ) ).'&paypal=1', // Post Affiliate Pro integration snippet

'notify_url' => $this->notify_url.'?pap_custom='.$_POST['pap_custom'], // Post Affiliate Pro integration snippet
 
4
Integration of PayPal module in WooCommerce - part 2
Now,
  • for WooCommerce 2.2.11 and lower: in the same file (woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php), find  function check_ipn_request_is_valid and into that function below the line of function check_ipn_request_is_valid add the code found in the box below

  • for WooCommerce 2.3.3 and higher: find and edit the file of woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-ipn-handler.php  and in that file find the validate_ipn() function. Within that function find the following line:
    if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {

    and right below that line add the code found in the box below
Save your work and continue with the next step.
5
Integration of PayPal module in WooCommerce - part 3
Edit the file woocommerce/templates/checkout/form-checkout.php:
Find this line:
<?php do_action( 'woocommerce_checkout_order_review' ); ?>

and place this code below the line:
6
Integration of PayPal module in WooCommerce - part 4
If you only use PayPal as your payment integration, you can ignore this step.

To make sure the integration does not create duplicate orders (one from PayPal and one from the thank you page), we have to set the thank you page to ignore commissions for PayPal orders.

To do so, you have to modify the thank you page tracking code a little. First, edit the file woocommerce/templates/checkout/thankyou.php and find this line:
<?php do_action( 'woocommerce_thankyou', $order->id ); ?>

Place this code below that line:
<?php 
if (empty($_GET['paypal'])) :
?>

Now, below the last integration lines:
PostAffTracker.register();
</script>

Add this code:
<?php endif; ?>
That's it. Save your work and the very last step is to activate your PayPal IPN handling plugin in your Post Affiliate Pro.
7
Integration with Stripe
If you want to integrated Stripe recurring payments, you can do it in few small steps. First of all, you should have followed the step 1 or 2 and also using the customer email in data1:
sale.setData1('<?php echo $order->billing_email; ?>');

To make Stripe let your PAP know about a recurring payment, you have to add a new webhook in your Stripe account, Your Account (top right)> Account Settings> Webhooks ... use this URL:
Besides this, you have to enable (and configure) the Stripe plugin and Lifetime Commissions plugin.
Do not forget to insert the click tracking code to your WP header or footer file, using Appearance menu.

NOTE:
In case the sale tracking does not work for you event the sale tracking code is at it's place, check if there is a special directory for woocommerce in your custom theme. If you found it, just integrate the /checkout/thankyou.php file there...

Recurring Commissions with WooCommerce Subscriptions

4 years ago Rick
I sell a monthly subscription product and need to credit affiliates when subscriptions are successfully renewed. I use paypal and authorize.net for payments.

How can we do this?

Subscription integration

4 years ago Martin Pullmann
Hi Rick,

if you want to integrate subscriptions, you have to integrate the payment gateway within WooCommerce. E.g. in case of PayPal, you have to work with the plugin found at wp-content/plugins/woocommerce/classes/gateways/paypal/

In case of Authorize.Net it is wp-content/plugins/woocommerce-authorize-net/

Paypal Digital Goods WooCommerce Plugin

2 years ago Mark
How to integrate in WooCommerce Extention Paypal Digital Goods. I hope you can help me with this

Thanks

PayPal digital goods

2 years ago Martin
Look for it in wp-content/plugins/woocommerce/classes/gateways/ and try to integrate it. If you can not, please contact our online help.

Using Stripe with Woo/PAP

2 years ago Jason
How would stripe, woo and PAP work together? Similar to the Paypal Setup? This would really help my setup as I don't want to use paypal. Thanks.

Pending orders

1 years ago Lucas
I need to know if the successful tracking occurs when the order is completed.

I have a lot of pending orders that never get paid and I don't want to pay commissions for them.

Thanks

how to Track affiliate sale when using Check as Payment

9 months ago Alain
Hi,

I'm wondering how to track if a sale is successful if the payment method used by a newly registered affiliate is via Check or other payment method that needs manual verification.


Cheers!

Seems complicated and requires high maintainence!

8 months ago Sid
hi

This seems to be a really old page from QU. It would be great if you could update this page.
One HUGE PROBLEM, i see with this is, obviously applying updates on Woocommerce plugin and themes. In todays modern WP world, plugins need updates on a daily basis. Similarly themes need to be updated atleast once in a month or a few months.

Would'nt it be easier for everyone if you could release a WP plugin that took care of the complete implementation?

Thanks

WP / WOO Plugin

8 months ago Daniel
i also looking for a plugin to integrate PAP in my Store. But without so many changes on code and will be able to track the leads without any restrictions on a payment gateway. can you develop such a plugin for your customers?

Thanks
Daniel

Plugin

8 months ago Robert Ruiz
We have been using PAP Ultimate for about a year now with our woocommerce cart
we use PayPal Pro PayFlow
As someone said a few weeks ago, Yes the theme & plugins have to be updated OFTEN
This makes it Impossible to maintain a working affiliate site 100% of the time because, as everyone knows, there are Bots out there trying to break in to wordpress sites on a daily basis, so we have to Auto - Update WP & our Plugins
EVERY Time there is an update we have to do a test order or wait for an order to go though & see if it posted to PAP
sometimes we get an order that will show up Twice in PAP, even though it was only ran once in the cart...
With the latest update to WP & Woocommerce & PayPal Pro Payflow, now it is not working again and I can not figure it out this time, so I will have to contact support, again....

A WP / Woocommerce plugin is needed Badly
Please make one, I can not imagine it would be that hard, it has got to be easier than having customers needing help or just giving up.

Another vote for an integration module!

5 months ago Merrick
Another vote here for a woocommerce integration module! Manually applying updates by hand is tedious & error prone.