• Lisa

    (@justmontessori)


    Can someone point me to the function in WooCommerce that, when envoked I can add a global cookie for “attribute_style-color?”

    I want to take the existing “attribute_style-color” used for my products, and set a cookie that carries that color throughout the website. Is that a GLOBAL variable in a cookie? Possible?

    I tried asking in another thread but no concrete solution found before the thread was closed. I’m familiar with code, but not expert, so need a hand holding response, please?

    Thank you in advance… Lisa

Viewing 4 replies - 1 through 4 (of 4 total)
  • Phil

    (@fullysupportedphil)

    Automattic Happiness Engineer

    To clarify, is this what you are trying to do:

    When a customer adds a specific product variation, you want to then automatically select a matching variation on all other products (based on attribute)?

    Or is it something else?

    If that’s what you wanted, I don’t think that would be possible. That being said, I’m not a developer myself.

    For these type of coding questions, you’re more likely to get input by asking in the WooCommerce Developer Slack or Advanced WooCommerce Facebook group. As those communities are both frequented by developers (including our own).

    Thread Starter Lisa

    (@justmontessori)

    Thank you for your response. Let me clarify what I would like to know:

    1) Can someone point me to the function in WooCommerce that is executed when adding an item to the cart?
    2) I want to extract “attribute_style-color” to set in a global cookie that persists in the browser for a period of time.
    3) When a visitor displays a page using that browser with the Cookie set, I want to grab the cookie VALUE which is “attribute_style-color=COLOR” and pass it to the drop-down as <option value=”COLOR” selected>COLOR</option>

    I know all these can be accomplished easily on their own, but need to know where the function in WooCommerce is to add the code, grab the COLOR in the Cookie, and then assign it to the attribute drop-down? If I add /?attribute_style-color=COLOR to my URL it will already do this.

    Hope that was clear… Lisa

    Thread Starter Lisa

    (@justmontessori)

    Thank you, Phil, for directing me to WooCommerce Developer Slack. I am making good progress, and I think it will be as straightforward as I thought, if one knows the WooCommerce functions.

    I’ll post final conclusion once I get everything working…

    Thanks again!

    Phil

    (@fullysupportedphil)

    Automattic Happiness Engineer

    Glad to hear that’s been a helpful resource @justmontessori

    If you do find a solution for what you wanted to do, certainly feel free to update the community here in case someone else has the same need.

    Cheers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘“Add to Cart” function’ is closed to new replies.