A couple of weeks ago I had a client with an unusual request. Their shop sells both retail and wholesale, but in their wholesale agreement there are two stipulations. When a new wholesale account is set up, the first purchase has a $750 minimum purchase. The second stipulation is all reorders have a $300 minimum purchase.
So I had to figure out how to set this up, since it is not a feature of Prestashop. Here is how I did it. There are 5 account types in this shop, the two that we are concerned with are the Wholesale (this is the account type with a $750 limit) the other one is Wholesale Verified (this has a $300 limit). When someone signs up for a wholesale account they placed into the Wholesale account group. Once they place their initial $750 order, they are moved to the Wholesale group. Below are the account groups of the shop.
In the back office I went to Preferences and then to Orders. Inside the orders page, I set the limit at $300. This will block any order from being placed that is under $300. But wait, retail customers can place orders at any amount. So I had to change how Prestashop validates the orders. Now, which file you edit depends on which checkout you have enabled.
What to edit for One Page Checkout around line 461 (in version 22.214.171.124) on the 5 Step Checkout, this is around line 61. The files you will need to be editing are classes/OrderOpcController.php or classes/OrderController.php
/* Check minimal amount */ $currency = Currency::getCurrency((int)$this->context->cart->id_currency); $customer = new Customer((int)($this->context->customer->id)); $Cgroups = $customer->getGroups(); if ($Cgroups==5) $minimalPurchase = Tools::convertPrice(Configuration::get('PS_PURCHASE_MINIMUM'), $currency); else if ($Cgroups==4) $minimalPurchase = 750; else $minimalPurchase = 1; if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase) return '
'.sprintf( Tools::displayError('Our wholesale agreement requires a $750 minimum first purchase and a $500 minimum restocking purchase.'), Tools::displayPrice($minimalPurchase, $currency) ).'';</pre>
Here is a screenshot of the code in an editor for reference.
If you have any problems with this, just drop us a line and we will try to lend you an hand.
About the Author: Lesley Paone
Lesley has worked in e-commerce for over a decade, and is the founder of dh42. Starting out with PrestaShop and brancing out into other platforms like Shopify. He loves all things e-commerce and loves a challenge, in his spare time he helps moderate several forums on SEO, e-commerce, as well as the PrestaShop forum. If you have any questions for him about any of his articles just use our contact form to contact him.