Unleash the Full Potential of Your PrestaShop Store

Welcome to MyPresta.eu – Your reliable partner in the e-commerce world. Find innovative modules that will take your business to a new level.

Prestashop loyality module - include tax to voucher value

Today i want to say something about default prestashop loyality module. In addon settings you can set up voucher code for your shop guests. They have got an ability to collect points in your loyality program, then they can change it into voucher codes. By default, loyality addon creates voucher codes without tax. In this article I want to show you how to create voucher codex with tax included to the voucher value.

 

1) Default controller code change

Unfortunately you have to edit module code. But it is very easy. For the first you need to open  default controller for this module located in /modules/loyality/controllers/front/default.php file. Searcj for code containing $cart_rule variables, exactly as below:

   $cart_rule = new CartRule();
   $cart_rule->code = $voucher_code;
   $cart_rule->id_customer = (int)$this->context->customer->id;
   $cart_rule->reduction_currency = (int)$this->context->currency->id;
   $cart_rule->reduction_amount = LoyaltyModule::getVoucherValue((int)$customer_points);
   $cart_rule->quantity = 1;
   $cart_rule->quantity_per_user = 1;

 

Right behind the $cart_rule->quantity_per_user =1; paste this: $cart_rule->reduction_tax = 1; So this piece of code should looks like: 

   $cart_rule = new CartRule();
   $cart_rule->code = $voucher_code;
   $cart_rule->id_customer = (int)$this->context->customer->id;
   $cart_rule->reduction_currency = (int)$this->context->currency->id;
   $cart_rule->reduction_amount = LoyaltyModule::getVoucherValue((int)$customer_points);
   $cart_rule->quantity = 1;
   $cart_rule->quantity_per_user = 1;
   $cart_rule->reduction_tax=1; 

As you can see, it is very easy. But what exactly $cart_rule->reduction_tax=1; variable means? This is indicator of tax included / excluded from the reduction / voucher code value. If you set this parameter to 1 - then reduction will be with tax, if you set it to 0 - then the value will be without tax.

 

It's easy, didn't it?

Zdjęcie autora: Milosz Myszczuk

Artykuł napisany przez Milosza Myszczuka, eksperta PrestaShop i oficjalnego moderatora społeczności PrestaShop. CEO i założyciel agencji interaktywnej VEKIA. Dowiedz się więcej.

If you like this article, support our work!

Comments