Jump to content

Set Cart Minimum with vouchers/discounts


Blootrice

Recommended Posts

Hello there,

 

I've already searched this issue in the forums and the internet but haven't found the exact same issue I'm trying correct.

 

- In Prestashop we can set the cart with a minimum cart value. But this value, doesn´t take into account discounts and vouchers. It purely sums up the cost of the products added to the cart.

- We need to set a cart total minimum(after discounts).

 

Exemple

- Let's say we need a minimum of 15€.

- If we add products in value of 12€ it fires up the warning.

- If we add products with a value o 16€ its good to go. But if we add a discount voucher of 2€, it now has a Cart Total of 14€, which is under the limit.

- We want always a cart minimum of 15€, with vouchers included.

 

In Prestashop the options are limited in this case. Or I'm searching in the wrong place.

I was hoping someone could shed some light on this issue.

 

Thanks in advance.

 

Best regards,

Bloo

Link to comment
Share on other sites

Hello again,
 
I've continued digging and found the solution.
 
You'll have to open OrderController.php. It's in controllers > front.
 
Around lines 68 and 72 you'll found this code:
       if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step > 0) {
  $_GET['step'] = $this->step = 0;
            $this->errors[] = sprintf(
                Tools::displayError('A minimum purchase total of %1s (tax excl.) is required to validate your order, current purchase total is %2s (tax excl.).'),
                Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency)
            );
        }
 
On the instances, where it says:
getOrderTotal(false, Cart::ONLY_PRODUCTS)
 
change to
 
getOrderTotal(false, Cart::BOTH_WITHOUT_SHIPPING)
 
It now sets the minimum taking in consideration the total with the discounts and vouchers.
 
The value False or true refers to the tax. If the value inserted in the back office is with or without tax.
 
Hope it will useful for someone.
 
Best regards,
Bloo

Edited by Blootrice (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...