In this blog, We will learn how we can skip or exclude the minimum purchase validation for any specific product in PrestaShop.
We are taking an example in which we skip this validation for membership plans.
Let’s Start..!
We can set this minimum purchase amount Shop Parameter > Order Setting > Minimum Purchase total required to validate an order. Check the image below.
After this, We can see, This configuration is validating all orders for this minimum purchase amount.
To manage this validation we need to register a hook “overrideMinimalPurchasePrice“. Follow the below code to register a hook.
$this->registerHook('overrideMinimalPurchasePrice');
Now we need to manage this hook according to our requirements. In the below code we are showing an example of a plan product.
public function hookOverrideMinimalPurchasePrice($params) { $cart = new Cart((int) $this->context->cart->id); $products = $cart->getProducts(); $isMembershipPlan = false; foreach ($products as $product) { $planInfo = $this->getPlanInfoByIdProduct( // Function to get product info $product['id_product'], $this->context->shop->id ); if ($planInfo) { $isMembershipPlan = true; } } if ($isMembershipPlan) { $params['minimalPurchase'] = 0; return $params; } return $params; }
In conclusion, You can see validation does not appear when we added a plan in the cart.
That’s all about this blog. Hope it will help you.
Also, you can explore our PrestaShop Development Services and a large range of quality PrestaShop Modules.
For any doubt contact us at [email protected]
I want to Skip the minimum purchase validation for a specific IP Address
Can you help me achieve it