Jump to content

How to set minimum order price per customer group in Prestashop 1.5


Recommended Posts

This page explains it very well,

http://doc.prestasho...es+And+Vouchers

 

The first part of the page is related to Cart Rules. These will come in handy down the road.

 

Scroll down to the second section “Catalog price rules”. That’s what you want right now.

 

Hope this helps.

 

______________________________________________________________________

 

I just want to restrict a specific customer group minimum order limit i.e $100, no need discount, voucher etc. This functionality is not in 'Catalog price rules' or in 'Cart rule'

Link to comment
Share on other sites

Ok, I guess I did not zero in on exactly what you want to do.

 

Please read the following and let me know if that is closer to what you need. (Sorry to keep giving you links, but it's better than typing)

 

 

How to set a minimum amount for cart rules in PrestaShop 1.5

Written By: Scott Mitchell

http://www.inmotionhosting.com/support/edu/prestashop-15/pshop15-price-rules/set-min-amount

 

 

Restrict cart rules to work with certain groups in PrestaShop 1.5

Written By: Scott Mitchell

http://www.inmotionhosting.com/support/edu/prestashop-15/pshop15-price-rules/specific-customer-group

Link to comment
Share on other sites

Ok, I guess I did not zero in on exactly what you want to do.

 

Please read the following and let me know if that is closer to what you need. (Sorry to keep giving you links, but it's better than typing)

 

 

How to set a minimum amount for cart rules in PrestaShop 1.5

Written By: Scott Mitchell

http://www.inmotionh.../set-min-amount

 

 

Restrict cart rules to work with certain groups in PrestaShop 1.5

Written By: Scott Mitchell

http://www.inmotionh...-customer-group

 

I really appreciate, you are helping me to find the solution. I have followed the above links carefully. I have create a new cart rule with minimum $150 price and i have select all 'Customer group selection' listed customers, but when i add products to cart and goes to opc page, after logged in, i have not found any notification to restrict me minimum $150.

 

I have cleared browser and project cache, but no any solution.

  • Like 1
Link to comment
Share on other sites

I now see your problem very clear. Sorry it took me so long. ;)

 

It is very easy to set the limit for the entire store.

 

Preferences > Orders > Minimum purchase total required in order to validate order

 

That is a quick easy way to set the limit for the entire store. But this setting would be MUCH more useful if it applied to Groups. For example when you create a group Prestashop offers a way to apply a discount to the Group members, and if this option was there as well it would be very useful to wholesale shops.

 

I searched the forums and I see you have already found a related thread were solutions have been hard coded in earlier versions of Prestashop. I would very much appreciate that if/when you find the answer that you post the solution here. It would be very much appreciated.

 

Also if anyone reading has a solution I hope you will let us know.

Link to comment
Share on other sites

I now see your problem very clear. Sorry it took me so long. ;)

 

It is very easy to set the limit for the entire store.

 

Preferences > Orders > Minimum purchase total required in order to validate order

 

That is a quick easy way to set the limit for the entire store. But this setting would be MUCH more useful if it applied to Groups. For example when you create a group Prestashop offers a way to apply a discount to the Group members, and if this option was there as well it would be very useful to wholesale shops.

 

I searched the forums and I see you have already found a related thread were solutions have been hard coded in earlier versions of Prestashop. I would very much appreciate that if/when you find the answer that you post the solution here. It would be very much appreciated.

 

Also if anyone reading has a solution I hope you will let us know.

 

Yes it is good, but i still need to set separately minimum order price per each customer group.

i found "Caution! The rule will automatically be applied if you leave this field blank" in 'Cart rules' is not working. I have tested it in new versions 1.5.3 and 1.5.3.1, but still automatically rule is not applying.

 

Anyway, I am still working on it, if i will find any solution, i will must share, Thanks

Edited by kashifkhan112 (see edit history)
  • Like 1
Link to comment
Share on other sites

I got here searching for the same exact thing! Couldn't find a solution yet. I think is pretty stupid that this option is not included into prestashop!

What I need is a bit more complicated:

- I want for a certain group of clients to be able to order only if they have a minimum total price value of products from manufacturer A or a minimum weight value of products from Manufacturer B.

 

What if we made a cart rule (using the minimum order condition) with a certain cupon and force this cupon onto the clients Group we want it to apply? Or something like that.

I really need this option and I would pay for it if someone could do it!

Link to comment
Share on other sites

This was driving me crazy as well so I found a way to make it work with PS 1.5.3.1.

Here's how I did it:

If you're using One Page Checkout, edit OrderOpcController.php. Find the line 452 and replace this:

 

/* Check minimal amount */
$currency = Currency::getCurrency((int)$this->context->cart->id_currency);

$minimalPurchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase)
return '<p class="warning">'.sprintf(
Tools::displayError('A minimum purchase total of %d is required in order to validate your order.'),
Tools::displayPrice($minimalPurchase, $currency)
).'</p>';

 

with this:

 

/* Check minimal amount dpcdpc11*/
$currency = Currency::getCurrency((int)$this->context->cart->id_currency);

$customer = new Customer((int)($this->context->customer->id));
$groupes = $customer->getGroups();

if ($groupes[0]==THE ID OF YOUR CLIENT GROUP)
$minimalPurchase = Tools::convertPrice(Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
else
$minimalPurchase = 1;

if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase)
return '<p class="warning">'.sprintf(
Tools::displayError('A minimum purchase total of %d is required in order to validate your order.'),
Tools::displayPrice($minimalPurchase, $currency)
).'</p>';

 

Now I want to take this even further and impose on this Client Group a restriction of a certain minimum Weight amount of a certain Manufacturer or a minimum total price of another Manufacturer.

I've managed to add the Weight limit but I dunno how to deal with the Manufacturer limit... here is how far I've got:

 

/* Check minimal amount dpcdpc11*/
$currency = Currency::getCurrency((int)$this->context->cart->id_currency);

$customer = new Customer((int)($this->context->customer->id));
$groupes = $customer->getGroups();

if ($groupes[0]==4)
$minimalPurchase = Tools::convertPrice(Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
else
$minimalPurchase = 1;

if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) > $minimalPurchase || $this->context->cart->getTotalWeight() > 100)
{
}
else
return '<p class="warning">'.sprintf(
Tools::displayError('A minimum purchase total of %d is required in order to validate your order.'),
Tools::displayPrice($minimalPurchase, $currency)
).'</p>';

 

I know it can be done but I don't have best programmer's skills.

So any help would be much appreciated!

Link to comment
Share on other sites

  • 3 weeks later...

This was driving me crazy as well so I found a way to make it work with PS 1.5.3.1.

Here's how I did it:

If you're using One Page Checkout, edit OrderOpcController.php. Find the line 452 and replace this:

 

/* Check minimal amount */
$currency = Currency::getCurrency((int)$this->context->cart->id_currency);

$minimalPurchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase)
return '<p class="warning">'.sprintf(
Tools::displayError('A minimum purchase total of %d is required in order to validate your order.'),
Tools::displayPrice($minimalPurchase, $currency)
).'</p>';

 

with this:

 

/* Check minimal amount dpcdpc11*/
$currency = Currency::getCurrency((int)$this->context->cart->id_currency);

$customer = new Customer((int)($this->context->customer->id));
$groupes = $customer->getGroups();

if ($groupes[0]==THE ID OF YOUR CLIENT GROUP)
$minimalPurchase = Tools::convertPrice(Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
else
$minimalPurchase = 1;

if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase)
return '<p class="warning">'.sprintf(
Tools::displayError('A minimum purchase total of %d is required in order to validate your order.'),
Tools::displayPrice($minimalPurchase, $currency)
).'</p>';

 

Now I want to take this even further and impose on this Client Group a restriction of a certain minimum Weight amount of a certain Manufacturer or a minimum total price of another Manufacturer.

I've managed to add the Weight limit but I dunno how to deal with the Manufacturer limit... here is how far I've got:

 

/* Check minimal amount dpcdpc11*/
$currency = Currency::getCurrency((int)$this->context->cart->id_currency);

$customer = new Customer((int)($this->context->customer->id));
$groupes = $customer->getGroups();

if ($groupes[0]==4)
$minimalPurchase = Tools::convertPrice(Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
else
$minimalPurchase = 1;

if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) > $minimalPurchase || $this->context->cart->getTotalWeight() > 100)
{
}
else
return '<p class="warning">'.sprintf(
Tools::displayError('A minimum purchase total of %d is required in order to validate your order.'),
Tools::displayPrice($minimalPurchase, $currency)
).'</p>';

 

I know it can be done but I don't have best programmer's skills.

So any help would be much appreciated!

 

@dpcdpc11

 

Am I reading this correctly?

 

I set the minimum order value for the whole shop at say £200

I set up a group with an ID of 10 called "Trade"

In your code I put

 

if ($groupes[0]==10)
$minimalPurchase = Tools::convertPrice(Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
else
$minimalPurchase = 1;

 

I have changed the ID of the group to 10 (the trade group)

 

Then what happens is that on check out a default customer will be subject to a minimum order value of £1 ($minimalPurchase = 1;) but anyone in the Trade group will get £200 minimum order?

Link to comment
Share on other sites

in the same orderopc file, after:

$currency = Currency::getCurrency((int)$this->context->cart->id_currency);

add:

 

/********* restrictions START ******************/
/* config data start */
$ID_manufacturer_with_price_restriction = 1;
$ID_manufacturer_with_weight_restriction = 2;
$ID_customer_group = 3;
$min_total_price_for_defined_manufacturer = 1000;
$min_total_weight_for_defined_manufacturer = 100;
/* config data end */
//init variables
$allow_to_order = true;
$total_price_for_defined_manufacturer = 0;
$total_weight_for_defined_manufacturer = 0;
if($this->context->customer->id_default_group == $ID_customer_group) {
$products = $this->context->cart->getProducts();
foreach($products as $product) {
 if($product['id_manufacturer'] == $ID_manufacturer_with_price_restriction) {
  $total_price_for_defined_manufacturer += $product['total'];
 }
 if($product['id_manufacturer'] == $ID_manufacturer_with_weight_restriction) {
  $total_weight_for_defined_manufacturer += $product['weight'];
 }
}
if($total_price_for_defined_manufacturer < $min_total_price_for_defined_manufacturer && $total_weight_for_defined_manufacturer < $min_total_weight_for_defined_manufacturer) {
 $allow_to_order = false;
}

if($allow_to_order === false) {
 return '<p class="warning">'.sprintf(
 Tools::displayError('A minimum purchase total of %d or of %d weight is required in order to validate your order.'),
 $min_total_price_for_defined_manufacturer, $min_total_weight_for_defined_manufacturer
 ).'</p>';
}
}
/********* restrictions END ******************/

Link to comment
Share on other sites

  • 4 months later...
  • 2 months later...

This was driving me crazy as well so I found a way to make it work with PS 1.5.3.1.

Here's how I did it:

If you're using One Page Checkout, edit OrderOpcController.php. Find the line 452 and replace this:

 

/* Check minimal amount */
$currency = Currency::getCurrency((int)$this->context->cart->id_currency);

$minimalPurchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase)
return '<p class="warning">'.sprintf(
Tools::displayError('A minimum purchase total of %d is required in order to validate your order.'),
Tools::displayPrice($minimalPurchase, $currency)
).'</p>';
with this:

 

/* Check minimal amount dpcdpc11*/
$currency = Currency::getCurrency((int)$this->context->cart->id_currency);

$customer = new Customer((int)($this->context->customer->id));
$groupes = $customer->getGroups();

if ($groupes[0]==THE ID OF YOUR CLIENT GROUP)
$minimalPurchase = Tools::convertPrice(Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
else
$minimalPurchase = 1;

if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase)
return '<p class="warning">'.sprintf(
Tools::displayError('A minimum purchase total of %d is required in order to validate your order.'),
Tools::displayPrice($minimalPurchase, $currency)
).'</p>';
Now I want to take this even further and impose on this Client Group a restriction of a certain minimum Weight amount of a certain Manufacturer or a minimum total price of another Manufacturer.

I've managed to add the Weight limit but I dunno how to deal with the Manufacturer limit... here is how far I've got:

 

/* Check minimal amount dpcdpc11*/
$currency = Currency::getCurrency((int)$this->context->cart->id_currency);

$customer = new Customer((int)($this->context->customer->id));
$groupes = $customer->getGroups();

if ($groupes[0]==4)
$minimalPurchase = Tools::convertPrice(Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
else
$minimalPurchase = 1;

if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) > $minimalPurchase || $this->context->cart->getTotalWeight() > 100)
{
}
else
return '<p class="warning">'.sprintf(
Tools::displayError('A minimum purchase total of %d is required in order to validate your order.'),
Tools::displayPrice($minimalPurchase, $currency)
).'</p>';
I know it can be done but I don't have best programmer's skills.

So any help would be much appreciated!

 

---

hi,

if i use 5 pages checkout? would ordercontroller.php around line 55?

change the same code?

Thank you for providing the code..

Link to comment
Share on other sites

  • 5 months later...
  • 5 months later...
  • 8 months later...
  • 1 year later...

In orderopccontroller.php line# 586

 

/* Check minimal amount */
        $currency = Currency::getCurrency((int)$this->context->cart->id_currency);

        $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
        $groups = Customer::getGroupsStatic((int)$this->context->cart->id_customer);
        $whgroup = false;
        foreach ($groups as $g) {
            if($g == 4)
            $whgroup = true;
        }
        if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $whgroup) {
            return '<p class="warning">'.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)
            ).'</p>';
        }

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 months later...
×
×
  • Create New...