Use minimum purchase with taxes included Prestashop 1.7

rimas06

Member
XNullUser
Joined
Feb 22, 2022
Messages
187
Reaction score
4
Points
18
NullCash
3
I had the problem for a client and decided to investigate. I found old post, so create this new one to help whoever may need it now.
The problem is that when using the minimum purchase that Prestashop has in "Store parameters -> Order configuration" this is compared with the total of products with taxes excluded and I needed to include taxes in the minimum purchase. Although it is not the best practice, I have found the solution by modifying the /src/Adapter/Presenter/Cart/CartPresenter.php file to add a new variable with the total of products including taxes and thus replace the one that does not have taxes in the validation below.
Added after line 327 in Prestashop 1.7.7.1
$productsTotalIncludingTax = $cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);//Added by Nimeos.co
Once we have the variable, we replace it in the validation and assignment of the "minimalPurchaseRequired" index at the end of the present() function of the same file.
return [
'products' => $products,
'totals' => $totals,
'subtotals' => $subtotals,
'products_count' => $products_count,
'summary_string' => $summary_string,
'labels' => $labels,
'id_address_delivery' => $cart->id_address_delivery,
'id_address_invoice' => $cart->id_address_invoice,
'is_virtual' => $cart->isVirtualCart(),
'vouchers' => $vouchers,
'discounts' => $discounts,
'minimalPurchase' => $minimalPurchase,
'minimalPurchaseRequired' => ($productsTotalIncludingTax < $minimalPurchase) ?//Mod by Nimeos.co
$this->translator->trans(
'A minimum shopping cart total of %amount% (tax excl.) is required to validate your order. Current cart total is %total% (tax excl.).',
[
'%amount%' => $this->priceFormatter->format($minimalPurchase),
'%total%' => $this->priceFormatter->format($productsTotalIncludingTax),//Mod by Nimeos.co
],
'Shop.Theme.Checkout'
) :
''
];
In this way, the minimum purchase including taxes will be taken.
Greetings
 

d-shilko

Well-known member
Pro
Master
Diamond
Elite
Joined
Jun 10, 2021
Messages
2,498
Reaction score
1,453
Points
113
NullCash
5,827
Hello. Next time this kind of information you should write in the Request thread!
 

zyhivan

Member
XNullUser
Joined
Aug 6, 2021
Messages
571
Reaction score
0
Points
16
NullCash
2,521
Wow. I'll try it! Thank you so much! Thank you so much!
 
Top