ZenCart integration
A user-friendly PHP-based shopping cart system.
How to integrate PostAffiliatePro with ZenCart
Integration with ZenCart is made by placing sale tracking script into the order confirmation page.
Edit template
To integrate ZenCart you should edit the order confirmation template. Open the file includes/templates/template_default/templates/tpl_checkout_success_default.php.
Locate integration place
Find the line with following code which should already exist in the file.
<div id="checkoutSuccessOrderNumber"><?php echo TEXT_YOUR_ORDER_NUMBER . $zv_orders_id; ?></div>
Integration
Copy & Paste the following code into the file, under the line found above:
<?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, the integration is finished. Now every time a sale occurs, the shop will call our script and register the sale commission.
Lifetime commissions integration
If you want to integrate the Lifetime commissions plugin, then just add the code below into the code from step 3. after this line:
$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();
}
Also you need to add this code:
sale.setData1(\''.$email.'\');
right after the:
sale.setOrderID(\''.$orderId.'\');
In case you want to know the payment method name used in the order, you can use this variable:
$orders->fields['payment_method']
zenCart + PayPal – part 1
In case you use PayPal as a payment gateway in ZenCart then a different integration approach is needed.
In ‘zenCart_installation_directory/includes/functions/html_output.php‘ find the following line:
$field = '<input type="hidden" name="' . zen_sanitize_string(zen_output_string($name)) . '"';
and replace it with this one:
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 – part 2
Into ‘zenCart_installation_directory/includes/templates/template_default/common/tpl_footer.php‘ add the following code:
<!-- 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 – part 3
Into ‘zenCart_installation_directory/ipn_main_handler.php‘ add the following code:
/* 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 */
That’s it.
Now, log in to the merchant panel of Post Affiliate Pro (Network), navigate to the “Plugins” section and activate the “PayPal IPN Handling” plugin.
NOTE: If you wish to enable Lifetime Commission integration when using this ‘zenCart + PayPal‘ integration method, then in the configuration of “PayPal IPN Handling” plugin turn on the ‘Support lifetime commission‘ option.
Do not forget to integrate your site with the click tracking code to make the sale tracking working correctly.
What is ZenCart?
ZenCart is an open-source e-commerce platform that empowers businesses to create and manage their online stores with ease. Designed for flexibility and extensive customization, ZenCart allows users to tailor their stores to handle various product types and layouts. The platform supports customizable displays, detailed product information, and a wide range of e-commerce functionalities, all built upon a robust database schema that accommodates diverse product layouts.
Originating from a fork of the osCommerce project in 2003, ZenCart has evolved significantly over the years. One of the notable enhancements was the introduction of a distinct template system, setting it apart from its origins. The transition from a table-based design to CSS layouts in version 1.3.x modernized the platform, improving both aesthetics and functionality. Despite challenges like updating SEO functionalities, ZenCart has cultivated a dedicated community that continuously develops numerous plugins to enhance its features.
ZenCart is tailored for online store owners who seek a customizable and scalable e-commerce solution. It caters to both beginners and experienced users desiring extensive control over their store’s design and functionality. Ideal for businesses looking for open-source solutions, ZenCart supports multiple languages and currencies, making it suitable for a global market.
Main Features of ZenCart
- Open-Source Flexibility: As an open-source platform, ZenCart offers high flexibility, allowing users to modify and enhance their online stores freely.
- Comprehensive E-Commerce Tools: It provides robust tools for product management and order processing, streamlining business operations.
- Customizable Interface: Users can personalize the interface and scalable design options to create a unique shopping experience.
- Third-Party Integrations: ZenCart supports extensive third-party integrations, enhancing functionality and adaptability.
- User-Friendly and Cost-Effective: With its free core version, ZenCart lowers the entry costs for businesses venturing into e-commerce.
- Strong Community Support: A vibrant community offers forums and documentation, assisting users in troubleshooting and optimizing their stores.
Understanding ZenCart’s Pricing Options
While ZenCart’s software is free to download and use, associated costs revolve around hosting services, SSL certificates for secure transactions, domain name purchases, and optional plugins for added features. Additional indirect costs may arise from customization needs and security enhancements essential for personalizing and maintaining an online store.
Key User Insights on ZenCart
Pros:
- Highly customizable and flexible platform.
- Free software reduces initial investment.
- Strong capabilities in product management and order processing.
Cons:
- Basic default design may require extensive customization for a modern appeal.
- Upgrading the platform can be complex, often necessitating technical expertise.
- Basic reporting system might need enhancement for advanced analytics.
Overall, users appreciate ZenCart for its flexibility and control over their online stores. However, they note a learning curve and the potential need for professional assistance with advanced configurations.
YouTube Reviews of ZenCart
- Zen Cart Review – A Beginner’s Guide to Open Source Ecommerce
- Zen Cart Setup and Overview
- Understanding Zen Cart – Tips and Tricks
Alternatives to ZenCart
If you’re exploring other options besides ZenCart, consider these e-commerce platforms:
Discover seamless Ubercart integration with Post Affiliate Pro! Our guide offers step-by-step instructions and code snippets for integrating Ubercart and PayPal, enhancing your Drupal-powered online store. Start your free trial today and boost your e-commerce success with Post Affiliate Pro's user-friendly affiliate marketing software.