This integration method is for Virtue Mart version 3. If you have a lower version, please navigate to the integration method named "Virtue Mart 2".

1.

Integrate offline payments (cash)

Open file plugins/vmpayment/standard/standard.php and find function plgVmConfirmedOrder. At the end of it, there is a line $cart->emptyCart - place the following code above it:

/* Post Affiliate Pro integration snippet */
$html .= '<script id="pap_x2s6df8d" src="http://URL_TO_PostAffiliatePro/scripts/salejs.php" 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."');
sale.setData1('".$order['details']['BT']->email."');
PostAffTracker.register();
</script>";
/* Post Affiliate Pro integration snippet */

Save your work.

2.

Integrate online payments

Open file _administrator/components/comvirtuemart/plugins/vmpsplugin.php and find function processConfirmedOrderPaymentResponse. Add the following code to it's beginning:

/* Post Affiliate Pro integration snippet */
$html .= '<script id="pap_x2s6df8d" src="http://URL_TO_PostAffiliatePro/scripts/salejs.php" 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."');
sale.setData1('".$order['details']['BT']->email."');
PostAffTracker.register();
</script>";
/* Post Affiliate Pro integration snippet */

That's it, it's integrated.


Do not forget to integrate the click tracking code, to make the sale tracking work correctly.