Skip to main content

Add discount programmatically in Opencart

To add the discount in opencart programmatically follow the following steps:

1. Open <projectFolder>/catalog/model/total/coupon.php
2. Add the code in the getTotal() function

$discount_total=0;
if($total>=0 && $total<=500){
  $discount_total=$total*0.1;
}else if($total>500 && $total<=1000){
  $discount_total=$total*0.2;
}else if($total>1000 && $total<=10000){
  $discount_total=$total*0.3;
}
*/
$total_data[] = array(
'code'       => 'discount',
'title'      => sprintf("My Special Discount"),
'value'      => -$discount_total,
'sort_order' => 4
);

3. Now add the products in the cart
4. Goto Cart page check your order info (See the sample screenshot)



Popular posts from this blog

The old company comeup with new brand MAXBEN - Logo meaning

I am so happy to design this logo for my friend Suresh Mahalingam to boost his paint business to the next level. The first step in his process is logo design. He had a clear idea about his business, processes, pricing and target audience. I just collect all those information from him and created the logo with some appropriate meanings. Check out the logo here