FROM CACHE - en_header

Passing Cookie To Checkout

3 0 4



I am building an affiliate referal type of application. I am using a script tag to check for a parameter that a customer will arrive on the homepage using for example.

The value of aff is then stored as a cookie on the page and set to expire in 30 days time. The only problem is ideally I want this cookie to be passed to the checkout so that it is sent with the order webhook.

I was following this discussion up until it mentions saving the value as a cart attribute. I can't find anything online about how to create a cart attribute from the homepage.

I have looked at using the ?ref= parameter instead but the cookie used for it only lasts 8 hours and I'm not sure If i can change that.

Hope someone can help!

Regards, Jack



Replies 3 (3)
3 0 4

For those that stumble across this.

I used document.cookie standard javascript to create the cookie with a custom name. 

I then used this:'/cart/update.js', { attributes: {trackingcode: cookieval}});

to post the tracking code to the checkout as an attribute. Took me a while to find that line of code but hope it helps someone!


New Member
1 0 0

I have the same problem that is trying to solved. Any luck with this? 

New Member
3 0 0

do u insert this in the checkout page itself?