Reading list Switch to dark mode

    Skip the minimum purchase validation for a specific product in PrestaShop

    Updated 26 April 2022

    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.

    Image-1-1

    After this, We can see, This configuration is validating all orders for this minimum purchase amount.

    Screenshot

    To manage this validation we need to register a hook “overrideMinimalPurchasePrice“. Follow the below code to register a hook.

    Searching for an experienced
    Prestashop Company ?
    Find out More
    $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.

    Result

    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]

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    2 comments

  • Mark Stak
    • Sunny Kumar (Moderator)
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home