I’m running an EE3.x site with User and Cartthrob installed.

I need a way to have data saved in the {exp:cartthrob:save_customer_info_form} form when not logged in, save to / override data previously saved in {exp:user:register} and/or {exp:user:edit} forms after logging in.

The situation is that users are able to shop around when not logged in, but need to set some store settings because we have different inventory based on method (pick or delivery) as well as different stores.

I have a {exp:cartthrob:save_customer_info_form} form that saves the users preferred method (pickup or delivery) and their preferred store (if pickup), or address (if delivery).

Here's what that settings page looks like:

enter image description here enter image description here

The gist of that template:

{!--<!-- [DELIVERY: LOGGED IN USERS] -->--}
{if logged_in}


        ...Cartthrob fields (standard address fields) mapped to User custom fields...


{!--<!-- [DELIVERY: LOGGED OUT USERS] -->--}


        ... (The difference between the delivery fields is if logged out, 
         we use google's autocomplete field type vs standard address



{!--<!-- [PICKUP: ALL USERS] -->--}


        ...Cartthrob fields (select option - entries in locations channel)
         mapped to User custom fields...


I have these User fields mapped in Cartthrob (along with all the address fields etc):

  • Shipping Company (shipping_company) == Preferred Store (preferred_store)
  • Shipping Option (shipping_option) == Current Method (current_method)

Users can save these settings if logged in or not. Users can also save these settings in the User module, when they register with the {exp:user:register} form, and on their profile settings page with the {exp:user:edit} form.

The issue I'm having is:

When a user already has an account and has previously saved their settings in User, but is shopping while not logged in, and saves their settings in Cartthrob, and then later logs in (to checkout etc), the settings saved in {exp:cartthrob:save_customer_info_form} are overridden by the User settings.

The issue with that is, the inventory may be different depending on the method and location. So if they're shopping to "pickup at location A" (inventory has been based off of these settings), and have items in their cart, then login, and those settings change to "delivery from location B" the whole inventory could be off, location B may not have the item in stock. And we don’t want to have to clear their cart on login.

How I could go about getting this to work, so that the {exp:cartthrob:save_customer_info_form} settings save over the User settings on login?

Note: If the member is logged in and updates settings here (in the Cartthrob form), it saves over whatever they had previously saved in User just fine.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.