Jump to content

Minimal Purchase per group Presta 1.6


Recommended Posts

Hello for all!!!

I had set the previous version of prestahshop (1.5), a condition where a specific group of customers would have to reach a minimum value to make the purchase. With the upgrade to the new version of prestashop (1.6), all groups are needing to reach this minimum. 
Could someone give me a hand?
 
url: www.shopsensual.com.br
presta: 1.6.0.8
  • Like 1

Share this post


Link to post
Share on other sites

  • 3 months later...

Hey!

 

I replaced this (OrderController.php) / PS1.6.0.9

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

        $orderTotal = $this->context->cart->getOrderTotal();
        $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
        if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step > 0)
        {
            $this->step = 0;
            $this->errors[] = sprintf(
                Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order 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)
            );
        }

With

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

		$orderTotal = $this->context->cart->getOrderTotal();
		$minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
/**/
		$customer = new Customer((int)(self::$cookie->id_customer));
		$groupes = $customer->getGroups();
/**/
		if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < 100 and ($groupes[0]==4) && $this->step > 0)
		{
			$this->step = 0;
			$this->errors[] = sprintf(
				Tools::displayError('A minimum purchase total of 100 (tax excl.) is required in order 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)
			);
		}
/**/
		
		if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step > 0)
		{
			$this->step = 0;
			$this->errors[] = sprintf(
				Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order 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)
			);
		}
		
/* END */

Change  bold-written numbers (false, Cart::ONLY_PRODUCTS) < 100 and ($groupes[0]==4) with your min. purchase and special group-id.

 

I know ... its dirty ....

 

Any other ideas?

Edited by Stadtsirene (see edit history)

Share this post


Link to post
Share on other sites

  • 3 months later...

Hi,
me too i need this modification and i made it in the file /controllers/front/OrderController.php.... but nothing happens :(
The group id i want to apply le limitation is number 4, like your example, but they can purchase without any limitation...
Any suggestions?

 

Thank you.

 

UPDATE:

sorry i use the OrderOpcController.php not the 5 steps OrderController.php.

I have find a solution for the one-step checkout (OrderOpcController.php):

 

Find and replace this:

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

		$minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
		if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase)
			return '<p class="warning">'.sprintf(
				Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order 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>';

with this:

/* Check minimal amount */
		$currency = Currency::getCurrency((int)$this->context->cart->id_currency);
		
		$customer = new Customer((int)($this->context->customer->id));
		$groupes = $customer->getGroups();
		
		if ($groupes[0]== 4)
		$minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
		else
		$minimalPurchase = 1;
		
		if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase)
			return '<p class="warning">'.sprintf(
				Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order 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>';

and set in your back-office the minimum purchase value. So in this exemple the customers in the group id 4 have the restriction amount set in the BO, and the other group id customes have the restriction of only 1 euro.

 

Work fine on my prestashop 1.6.0.9

Thank you!

Edited by Drazh (see edit history)

Share this post


Link to post
Share on other sites

  • 2 months later...

Hello,

 

I want to do something similar to @paulormf. I want to be able to add different minimum order amount depending the Country.

For example i want the "Germany" to have a minimum amount of 50€ but "Greece" have a minimum amount of 10€.

 

Is something like this possible?

 

Any help appreciated.

 

Best Reagrds.

Share this post


Link to post
Share on other sites

  • 2 months later...

Hi,

me too i need this modification and i made it in the file /controllers/front/OrderController.php.... but nothing happens :(

The group id i want to apply le limitation is number 4, like your example, but they can purchase without any limitation...

Any suggestions?

 

Thank you.

 

UPDATE:

sorry i use the OrderOpcController.php not the 5 steps OrderController.php.

I have find a solution for the one-step checkout (OrderOpcController.php):

 

Find and replace this:

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

		$minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
		if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase)
			return '<p class="warning">'.sprintf(
				Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order 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>';

with this:

/* Check minimal amount */
		$currency = Currency::getCurrency((int)$this->context->cart->id_currency);
		
		$customer = new Customer((int)($this->context->customer->id));
		$groupes = $customer->getGroups();
		
		if ($groupes[0]== 4)
		$minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
		else
		$minimalPurchase = 1;
		
		if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase)
			return '<p class="warning">'.sprintf(
				Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order 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>';

and set in your back-office the minimum purchase value. So in this exemple the customers in the group id 4 have the restriction amount set in the BO, and the other group id customes have the restriction of only 1 euro.

 

Work fine on my prestashop 1.6.0.9

Thank you!

 

Help , I do not work well , is like ignoring the modified code because:

1. The system limiting the minimum order for all groups that I have in prestashop .

 

2. The notice displayed is given by a module file ( onepagecheckoutps.php ) , not the OrderOpcController.php

 

Regards :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More