How to set a custom cookie that carries attribute selection from page to page?
-
I am building a WooCommerce site for purchase of cabinets. Each cabinet has two attributes, “Style/Color” and “Size.” I’ll try to explain my needs clearly.
Customers buying cabinets for kitchen or bathroom will usually stick to the same color. I want to make it convenient for them to not have to select the color for every cabinet.
Once someone chooses a Style/Color and Size from the drop-down and adds the product to the cart, I assume they will continue to select other cabinets wanting the same color. So, I want to do set a cookie that carries from page to page and automatically sets the OPTION VALUE in the dropdown to that color (so they don’t have to keep selecting the Style/Color option).
If they DO happen to select another color for some reason, then the cookie gets reset to that color and the next cabinet they choose will now have the OPTION VALUE updated with that new Style/Color.
What is the code for doing this, and where would it go?
LONG VERSION
1) Set initial cookie upon adding first item to cart (reasoning: customer committed enough to Style/Color to start buying process)
2) If cookie exists, set OPTION VALUE in dropdown to that Style/Color for every page where Style/Color VALUE exists (reasoning: customer will select cabinets with same Style/Color for whole kitchen)
3) Only update color if another item is added to cart with a different Style/Color (reasoning: customer either made a mistake or is selecting new Style/Color for other room)SHORT VERSION
Need dropdown value of attribute to automatically be Style/Color (like Shaker Cinder) set in cookie when item is added to cart. The only time Style/Color would change is if customer added item to cart with a different color. Cookie needn’t expire.If there is already a way to do this, please advise. If not, please help!
The page I need help with: [log in to see the link]
- The topic ‘How to set a custom cookie that carries attribute selection from page to page?’ is closed to new replies.