OpenCart 3
Integrate OpenCart 3 with Post Affiliate Pro for enhanced e-commerce tracking. Follow steps to edit confirm and success actions for order, commission, and coupon tracking. Supports both whole cart and per product transaction processing.
OpenCart 3 integration
A free shopping cart system. OpenCart is an open-source PHP-based online e-commerce solution.
This is an integration method for open source shopping cart OpenCart version 3. The integration is done by integrating files of thank you page.
You can track per product orders, lifetime commissions, and also coupons.
Edit confirm action
Navigate to your cart directory catalog/controller/checkout and open confirm.php for editing. Find this line:
$data['totals'] = array();
Put this code below that line:
$this->session.data['totals'] = $order_data['totals'];
$this->session.data['pap4_products'] = $data['products'];
Save these files and continue with the next step.
Edit success action
Open file catalog/controller/checkout/success.php and find this line (first occurrence):
if (isset($this->session.data['order_id'])) {
Place the following code directly below that line and above the line with $this->cart->clear();
:
$data['pap4_orderid'] = $this->session.data['order_id'];
$data['pap4_totals'] = $this->session.data['totals'];
$data['pap4_products'] = $this->session.data['pap4_products'];
if ($this->customer->isLogged()) {
$data['pap4_email'] = $this->customer->getEmail();
}
else {
$data['pap4_email'] = $this->session.data['guest']['email'];
}
unset($this->session.data['pap4_products']);
Again, do not forget to save the changes and continue to the next integration step.
Whole cart as one transaction – Edit success view
If you want to process the whole payment as one transaction in PAP, follow this step. If you want to create one transaction for every product, continue to step 4.
Open file / catalog/view/theme/default/template/common/success.twig.
Add these lines before the last line which says {{ footer }}:
{# [Post Affiliate Pro](https://www.postaffiliatepro.com/ "Post Affiliate Pro offers a comprehensive affiliate software platform to manage multiple affiliate programs with ease. Enjoy no setup fees, 24/7 customer support, and a free 1-month trial. Ideal for small and large businesses, it features precise tracking, automated workflows, and customizable tools to boost your affiliate marketing success. Try it now and streamline your affiliate operations effortlessly!") integration #}
{% if pap4_totals is defined and pap4_orderid is defined and pap4_email is defined %}
{% set subtotal = 0 %}
{% for item in pap4_totals %}
{% if item.code == 'sub_total' %} {% set subtotal = subtotal + item.value %} {% endif %}
{% if item.code == 'coupon' %} {% set subtotal = subtotal + item.value %} {% endif %}
{% if item.code == 'voucher' %} {% set subtotal = subtotal + item.value %} {% endif %}
{% endfor %}
{% if subtotal < 0 %} {% set subtotal = 0 %} {% endif %}
<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('{{subtotal}}');
sale.setOrderID('{{pap4_orderid}}');
sale.setData1('{{pap4_email}}');
PostAffTracker.register();
</script>
{% endif %}
{# /[Post Affiliate](https://www.postaffiliatepro.com/ "Post Affiliate Pro offers a comprehensive affiliate software platform to manage multiple affiliate programs with ease. Enjoy no setup fees, 24/7 customer support, and a free 1-month trial. Ideal for small and large businesses, it features precise tracking, automated workflows, and customizable tools to boost your affiliate marketing success. Try it now and streamline your affiliate operations effortlessly!") Pro integration #}
Save the file. Your shop has just been integrated.
Note: The values of ‘Coupon’ and ‘Voucher’ are negative, that is why we are directly adding it to the subtotal value.
One transaction per product – Edit success view
This step is not necessary if you’ve already followed step 3.
Open file / catalog/view/theme/default/template/common/success.twig.
Add these lines before the last line which says {{ footer }}:
{# Post Affiliate Pro integration #}
{% if pap4_totals is defined and pap4_orderid is defined and pap4_email is defined %}
<script id="pap_x2s6df8d" src="https://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">
PostAffTracker.setAccountId('Account_ID');
{% for item in pap4_products %}
var sale{{ loop.index }} = PostAffTracker.createSale();
sale{{ loop.index }}.setTotalCost('{{ item.total }}');
sale{{ loop.index }}.setProductID('{{ item.product_id }}');
sale{{ loop.index }}.setOrderID('{{ pap4_orderid }}({{ loop.index }})');
sale{{ loop.index }}.setData1('{{ pap4_email }}');
{% if loop.last != false %}
sale{{ loop.index }}.doNotDeleteCookies();
{% endif %}
{% endfor %}
PostAffTracker.register();
</script>
{% endif %}
{# /Post Affiliate Pro integration #}
This will register a commission per each ordered product.
Do not forget to integrate your cart with the click tracking code to make the sale tracking work. You can place the click tracking code to the theme footer file:
/ catalog/view/theme/YOUR_THEME/template/common/footer.twig.
NOTE: In case you do not see the click tracking code even after cache refresh it means your theme files are not located in /catalog/view/theme/ but in /storage/modifications/catalog/view/theme. In that case find the file there and integrated it. Do the same with success.twig file.
Frequently asked questions
- What is OpenCart 3 integration with Post Affiliate Pro?
It is a step-by-step method to connect your OpenCart 3 e-commerce platform with Post Affiliate Pro for tracking orders, commissions, and coupon usage.
- What features does the integration provide?
The integration allows tracking per product orders, lifetime commissions, and coupon usage, supporting both whole-cart and per-product transaction tracking.
- Is OpenCart 3 integration with Post Affiliate Pro free?
Yes, OpenCart is a free open-source shopping cart, and Post Affiliate Pro offers a 1-month free trial for new users.
- What files need to be edited for integration?
You need to modify the confirm.php, success.php, and success.twig files in your OpenCart 3 installation following the provided instructions.
- Can I track one transaction per product or for the whole cart?
Yes, the integration guide provides options for both whole cart as one transaction or one transaction per product.
Lucia is a talented content editor who ensures the seamless publication of content across multiple platforms.

Start Your Free Trial with Post Affiliate Pro
Experience seamless affiliate tracking and management. Integrate your OpenCart 3 store and boost your affiliate marketing success today.