Virtue Mart 2 integration
A free e-commerce solution.
This integration method is for Virtue Mart version 2. If you have lower version, please navigate to the integration method named “Virtue Mart”.
Virtue Mart with PayPal in Joomla
First step is to edit file /plugins/vmpayment/paypal/paypal.php of your Joomla installation.
Find function plgVmConfirmedOrder($cart, $order) and in the function find line:
$html.= '</form>';
It can also be like this:
$html .= '</form></div>';
Now add this code right after the above:
$html.= '<script id="pap_x2s6df8d" src="https://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">'."
PostAffTracker.setAccountId('Account_ID');
PostAffTracker.setAppendValuesToField('&pap_custom=');
PostAffTracker.writeCookieToCustomField('pap_ab78y5t4a');
</script>";
Virtue Mart with PayPal in Joomla
Now one more change is needed – find the line:
$html.= '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value) . '" />';
and replace it with this:
if ($name == "notify_url") {$id='id="pap_ab78y5t4a"';} else {$id="";}
$html.= '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value) . '" '.$id." />\n";
Now save your work, there is another step to be done.
Virtue Mart with PayPal in Joomla
Final step is to resend response from PayPal to Post Affiliate Pro. To do this, find this line in the same file: function _processIPN($paypal_data, $method) {
Add this code right below this line (create a new blank line) and past the code there:
// Post Affiliate Pro integration snippet
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://URL_TO_PostAffiliatePro/plugins/PayPal/paypal.php?pap_custom=".$_GET['pap_custom']);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
curl_exec($ch);
// /Post Affiliate Pro integration snippet
This is it. Now save your file and upload it back to the server. Do not forget to enable PayPal plugin in your Post Affiliate Pro.
Virtue Mart with COD in Joomla
In case of Cash on delivery (COD) you have to modify the file /plugins/vmpayment/standard/standard.php and insert the sale tracking code there.
Find the line: $cart->emptyCart ();
and paste this code above that line:
$html.= '<!-- Post Affiliate Pro sale tracking code -->
<script id="pap_x2s6df8d" src="https://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">'
."PostAffTracker.setAccountId('Account_ID');"
.'var sale = PostAffTracker.createSale();
sale.setTotalCost(\''.$order['details']['BT']->order_subtotal.'\');
sale.setOrderID(\''.$order['details']['BT']->order_number.'\');
PostAffTracker.register();
</script>';
That’s it. Save your work and upload it back to the server.
Here is a list of all variables you can use:
$order['details']['BT']->order_total
$order['details']['BT']->order_subtotal
$order['details']['BT']->tax
$order['details']['BT']->coupon_discount
$order['details']['BT']->coupon_code
$order['details']['BT']->order_status
Virtue Mart with Cheque in Joomla
In case of Cheque payment method you have to modify the file /plugins/vmpayment/standard/standard.php and insert the sale tracking code there.
Find the line:
$modelOrder->updateStatusForOneOrder ($order['details']['BT']->virtuemart_order_id, $order, TRUE);
and paste this code below that line:
/* Post Affiliate Pro integration snippet */
$html .= '<script id="pap_x2s6df8d" src="https://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">
PostAffTracker.setAccountId(\'default1\');
var sale = PostAffTracker.createSale();
sale.setTotalCost(\''.$order['details']['BT']->order_subtotal.'\');
sale.setOrderID(\''.$order['details']['BT']->order_number.'\');
PostAffTracker.register();
</script>';
/* /Post Affiliate Pro integration snippet */
Save your work and you are done. You can use the same extra variables described in step 10.
Virtue Mart with GoogleCheckout in Joomla
The first step is to edit file /plugins/vmpayment/osegooglecheckout/osegooglecheckout.php and to find function plgVmConfirmedOrder.
Now, find line (in the end of the function):
$html.= '</form>';
Now change this line to these lines instead:
/* Post Affiliate Pro integration snippet */
$html.= '<input id="pap_dx8vc2s5" type="hidden" name="shopping-cart.items.item-1.merchant-private-item-data" value="" />';
$html.= '<script id="pap_x2s6df8d" src="//URL_TO_PostAffiliatePro/scripts/notifysale.php" type="text/javascript">'."\n".'</script>';
$html.= '</form>';
/* /Post Affiliate Pro integration snippet */
Additionally, change line:
$html.= ' document.vm_google_form.submit();';
to this line:
$html.= ' setTimeout("document.vm_google_form.submit()",3600);';
This will ensure the tracking will work with GoogleCheckout buttons.
Virtue Mart with GoogleCheckout in Joomla
The second and the last step of GoogleCheckout integration is to place cURL code to its correct place – find the function plgVmOnPaymentResponseReceived and place the following code to the start of the function:
/* Post Affiliate Pro integration snippet */
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
"https://URL_TO_PostAffiliatePro/plugins/GoogleCheckout/googlecheckout.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
curl_exec($ch);
/* /Post Affiliate Pro integration snippet */
Note: URL https://URL_TO_PostAffiliatePro/plugins/GoogleCheckout/googlecheckout.php must be on secure domain (More on Google documentation).
Do not forget to integrate the click tracking code, to make the sale tracking work correctly.
Explore seamless integrations with Post Affiliate Pro to enhance your affiliate marketing strategies. Discover solutions for e-commerce, email marketing, payments, and more, with easy integrations for platforms like 1&1 E-Shop, 2Checkout, Abicart, and many others. Optimize your affiliate network with these powerful tools.
Discover seamless integration of OpenCart 2 with Post Affiliate Pro, an open-source PHP-based e-commerce solution. Enhance your marketing strategy with affiliate programs, track orders and lifetime commissions, and utilize coupons effectively. Follow step-by-step guides to edit cart directories and success actions, maximizing your business outreach. Start your free trial today and elevate your e-commerce game!