luizlaf Posted January 26, 2014 Share Posted January 26, 2014 Prestashop 18.104.22.168 standard 1 multi store system 1 employee for each store Requirements: Due to privacy concerns, customer information is only available (customer is created under the store) when adding a product to cart in that store. Visualize all carts/orders from all stores. My proposed approach: A system wise table with a master-customer information and the id_customer for each store. A single entry point to the system, where I ensure master-customer is created and logged in. When customer clicks on add-to-cart button, check on master-customer table if customer exists on that store, if yes- automatic login to the store, if not- create a customer in that store, add reference to the master-customer table and automatically login customer. Now that the customer is logged in, the cart can be created (or retrieved) for that customer specifically. My progress so far: Master-customer table is created and user logs in fine. Product page is displayed (store-wise customer is not logged in yet) When customer clicks on add-to-cart I need to check and create customer in that store. Under function assignContentVars($params) of blockcart.php Check from master-customer, assuming the customer exists in that store already (returns id_customer for that shop) $customer = new Customer((int)$result['id_cust_shop']); Context::getContext()->customer = $customer; Context::getContext()->customer->logged = true; Rest of the function... The cart is being created, but the customer information is not being inserted (as if the customer is not logged in). if I insert the code below just before the end of the function: $this->context->cart->id_customer = (int)$customer->id; $this->context->cart->secure_key = $customer->secure_key; $this->context->cart->save(); The cart is created with the correct customer information, but somehow 3 carts are created... Questions: Any better approach to achieve this? Is the code I produced in the right place (function assignContentVars($params))? Am I doing the right automatic login (apparently not, even though when I check $customer->isLogged() returns true) Why is the cart not initially created with the id_customer, and with the 2nd session of the code I get multiple creations? Thanks for the help! 1 Link to comment Share on other sites More sharing options...
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
Already have an account? Sign in here.Sign In Now