ZenCart integration
Un sistema di carrello degli acquisti user-friendly basato su PHP.
L’integrazione con ZenCart avviene inserendo lo script di tracciamento della vendita nella pagina di conferma dell’ordine.
Modifica il modello
Per integrare ZenCart devi modificare il modello di conferma dell’ordine. Apri il file includes/templates/template_default/templates/tpl_checkout_success_default.php.
Trova il luogo dell’integrazione
Trova la linea con il seguente codice che dovrebbe già esistere nel file.
<div id="checkoutSuccessOrderNumber"><?php echo TEXT_YOUR_ORDER_NUMBER . $zv_orders_id; ?></div>
Integrazione
Copia & incolla il seguente codice nel file, sotto la linea trovata sopra:
<?php
$dbreq = $db->Execute("select * from ".TABLE_ORDERS_TOTAL." where orders_id = '".(int)$orders->fields['orders_id']."' AND class in ('ot_coupon', 'ot_gv', 'ot_subtotal', 'ot_group_pricing', 'ot_quantity_discount')");
while (!$dbreq->EOF) {
switch ($dbreq->fields['class']) {
case 'ot_subtotal': $order_subtotal = $dbreq->fields['value']; break;
case 'ot_coupon': $coupon_amount = $dbreq->fields['value']; $coupon_code = $dbreq->fields['title']; break;
case 'ot_group_pricing': $group_pricing_amount = $dbreq->fields['value']; break;
case 'ot_gv': $gv_amount = $dbreq->fields['value']; break;
case 'ot_quantity_discount': $quantity_discount_amount = $dbreq->fields['value']; break;
}
$dbreq->MoveNext();
}
$totalCost = ($order_subtotal - $gv_amount - $coupon_amount - $group_pricing_amount - $quantity_discount_amount);
$totalCost = number_format($totalCost,2,'.','');
$orderId = $dbreq->fields['orders_id'];
// ------------- coupon code --------------------------------------------------
$coupon_code = substr($coupon_code,(strpos($coupon_code,":"))+2);
$coupon_code = substr($coupon_code,0,strlen($coupon_code)-2);
// -------------products---------------------------------------------------------
$productId = "";
$dbreqa = $db->Execute("select products_id from ".TABLE_ORDERS_PRODUCTS." where orders_id = '".(int)$orders->fields['orders_id']."' ");
while (!$dbreqa->EOF) {
$productId = $dbreqa->fields['products_id'];
$dbreqa->MoveNext();
}
// ----------end products--------------------------------------------------------
print '<script id="pap_x2s6df8d" src="https://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">';
print "PostAffTracker.setAccountId('Account_ID');";
print 'var sale = PostAffTracker.createSale();
sale.setTotalCost(\''.$totalCost.'\');
sale.setOrderID(\''.$orderId.'\');
sale.setProductID(\''.$productId.'\');
sale.setCoupon(\''.$coupon_code.'\');
PostAffTracker.register();
</script>';
?>
Ok, l’integrazione è stata completata. Ora ogni volta che si verificherà una vendita, il negozio attiverà il nostro script e registrerà la commissione di vendita.
Integrazione delle lifetime commissions
Se vuoi integrare il plugin Lifetime commissions, allora aggiungi semplicemente il codice qui sotto nel codice del passaggio 3. dopo questa linea:
$orderId = $dbreq->fields['orders_id'];
$dbreq = $db->Execute("select * from ".TABLE_ORDERS_TOTAL." where orders_id = '".(int)$orders->fields['orders_id']."' ");
while (!$dbreq->EOF) {
$email = $dbreq->fields['customers_email_address'];
$dbreq->MoveNext();
}
Inoltre dovrai aggiungere questo codice:
sale.setData1(\''.$email.'\');
proprio dopo il:
sale.setOrderID(\''.$orderId.'\');
Se vuoi sapere il nome del metodo di pagamento utilizzato nell’ordine, puoi usare questa variante:
$orders->fields['payment_method']
zenCart + PayPal – parte 1
Se usi PayPal come gateway di pagamento in ZenCart, allora dovrai utilizzare un metodo di integrazione diverso.
In ‘zenCart_installation_directory/includes/functions/html_output.php‘ trova la seguente linea:
$field = '<input type="hidden" name="' . zen_sanitize_string(zen_output_string($name)) . '"';
e cambiala con questa qui:
if ($name == 'notify_url') {
$field = '<input type="hidden" id="pap_ab78y5t4a" name="' . zen_output_string($name) . '"';
} else {
$field = '<input type="hidden" name="' . zen_output_string($name) . '"';
}
zenCart + PayPal – parte 2
In ‘zenCart_installation_directory/includes/templates/template_default/common/tpl_footer.php‘ aggiungi il seguente codice:
<!-- PAP Integration snippet -->
<script id="pap_x2s6df8d" src="https://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">
PostAffTracker.setAccountId('default1');
PostAffTracker.writeCookieToCustomField('pap_ab78y5t4a', '', 'pap_custom');
</script>
<!-- /PAP Integration snippet -->
zenCart + PayPal – parte 3
In ‘zenCart_installation_directory/ipn_main_handler.php‘ aggiungi il seguente codice:
/* Post Affiliate Pro integration snippet */
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://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 */
E questo è tutto.
Ora, accedi al merchant panel di Post Affiliate Pro (Network), vai alla sezione “Plugin” e attiva il plugin “PayPal IPN Handling“.
NOTA BENE: Se vuoi abilitare l’integrazione Lifetime Commission quando utilizzi questo metodo di integrazione ‘zenCart + PayPal’, allora nella configurazione del plugin “PayPal IPN Handling” dovrai attivare l’opzione ‘Supporto lifetime commission‘.
Non dimenticarti di integrare il tuo sito con il codice di tracciamento dei clic per far funzionare correttamente il tracciamento delle vendite.
How can I Become an Affiliate for Post Affiliate Pro tracking software?
Join the Post Affiliate Pro affiliate program! Sign up now to earn commissions by promoting top tracking software. Start today!
9. Integrate the affiliate software with your website
Integrate your affiliate software seamlessly with your website for effective tracking of referrals and commissions. Set it up right!
Easily integrate Post Affiliate Pro or Post Affiliate Network with WordPress using our plugin to track clicks, register new users as affiliates, and monitor contact form submissions. Activate click tracking, automate affiliate signups, and utilize affiliate shortcodes to enhance your website's functionality. Download now to streamline your affiliate management directly from WordPress.
Example answers for the integration service email
Unlock seamless integration with Post Affiliate Pro! Get free setup of your affiliate program by answering key questions about your website, payment gateways, and commission preferences. Ensure smooth access by securely sharing login details. Visit now for an effortless affiliate program launch!
Complimentary White Glove Setup & Full Integration Service
Start your affiliate program effortlessly with our free White Glove Setup & Integration Service—no fees, no contracts, just results!