Jump to content

Change Customer Group Automatically based on quantity in Cart


Recommended Posts

Hi everyone,

 

Sorry have to ask help on this issue, but i'v tried search in forums but still got no clue.

 

When a customer login to checkout or a guest create new account to checkout process. I need to change automatically the customer's group to another group based on how much of the quantity in his cart.

 

Please tell how to do this or any thread related to this issue.

 

Thanks..

Link to comment
Share on other sites

We needed to assign a customer at registration to the default group by domain name.

 

You can use this as an example, it's a class override of class/Customer.php (use this class to see different functions you would use for your project)

 

Customer.php

would be placed in override/classes/

this is an example of setting the default group differently based 'at registration' with on our own custom values

<?php
class Customer extends CustomerCore
{
public function add($autodate = true, $nullValues = true)
{
	if (empty($this->id_default_group))
		$this->id_default_group = Configuration::get('PS_DEFAULT_CUSTOMER_GROUP');
	return parent::add();
}
}
?>

you will most likely need an override of a different class, that can be used on add to cart calls

Happy prestashopping

Edited by elpatron (see edit history)
Link to comment
Share on other sites

Thank you Elpatron, yes I got the point

 

My Another newbie questions :

 

1. How to get the cart quantities in the classes/Customer.php to be included in IF Condition before we assign new group to existing or new customer ?

2. How to call customer update function to change group on existing customer.

Link to comment
Share on other sites

Thank you Elpatron, yes I got the point

 

My Another newbie questions :

 

1. How to get the cart quantities in the classes/Customer.php to be included in IF Condition before we assign new group to existing or new customer ?

2. How to call customer update function to change group on existing customer.

 

1. I updated my original response and added this "you will most likely need an override of a different class, that can be used on add to cart calls"

2. in the class (that you need to override), simply use a call like Customer::the_function you need. Groups is always an array because a customer can belong to one or more groups.

 

you will need to work out the particulars for your project...

Link to comment
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
×
×
  • Create New...