PrestaShop integration
An open source ecommerce software that helps to create a successful online stores for free.
Fast, efficient and easy to use, PrestaShop’s free e-commerce solution provides everything you need to open, operate and maintain a successful online store.
Integration using PrestaShop module
The easiest way to integrate PrestaShop with Post Affiliate Pro (Network) is to use our integration module (free downloadable module by Quality Unit, version 3.20.4)
It is a standard PrestaShop module which you can install as any other module. Configure it after installation and integration is done. The plugin automatically integrates all the needed integration codes.
NOTES:
- If you are using performance setting “Move JavaScript to the end” in your PrestaShop, please turn it off as it breaks down the tracking functionality.
- The module is currently tested with PrestaShop version 1.7.6.7. The module might very well work with newer versions as well, we just didn’t test it or we simply haven’t updated this note yet.
Localization of file and add tracking code (older versions of PrestaShop)
Connect to your FTP and find the file order-confirmation.php . This file process orders. Download it, open it in any text editor and find this line:
'HOOK_PAYMENT_RETURN' => Hook::paymentReturn(intval($id_order), intval($id_module))));
Add this tracking code after the line mentioned above. The code is for tracking total cost and order ID:
?><script id="pap_x2s6df8d" src="https://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">
var sale = PostAffTracker.createSale();
sale.setTotalCost('<?php echo $order->total_paid_real; ?>');
sale.setOrderID('<?php echo $id_order; ?>');
PostAffTracker.register();
</script>
<?php
Now save the file and upload it back to FTP.
PayPal part 2
Next thing to do is to find file validation.php, also inside shop/modules/paypal/. Edit this file and find this line of code:
$ch = curl_init('https://' . $paypalServer . '/cgi-bin/webscr');
Put following code right after that line of code:
/* PAP4 integration */
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://URL_TO_PostAffiliatePro/plugins/PayPal/paypal.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
curl_exec($ch);
/* end of PAP4 integration */
Also, you have to activate PayPal IPN plugin inside of your Merchant panel > Plugins. Edit the plugin settings and change separator to ||.
PayPal part 3
Last thing to do is to find this line of code inside validation.php:
if ($result == 'VERIFIED') {
Put following code right after that line of code:
/* PAP INTEGRATION */
$separator = '||';
if ($_POST['custom'] != '') {
$explodedCustomValue = explode($separator, $_POST['custom'], 2);
if (count($explodedCustomValue) == 2) {
$_REQUEST['custom'] = $_POST['custom'] = $explodedCustomValue[0];
}
}
/* END PAP INTEGRATION */
That’s all necessary in order to integrate PrestaShop + PayPal.