Liquid, JavaScript, themes, sales channels
Hello!
I'm looking to persist query parameters from the product page or homepage, all the way through to the checkout so that they are stored as cart attributes.
An example of what it would look like:
https://www.hydroponicsgreenhouse.com/products/mediterranean-refresh-third-edition?variant=323408562...
In this case I'd want the eftid cart attribute to pass through to the checkout, to allow it to be accessible in the Additional Scripts area on my store.
An example of a cart where this works:
http://hydroponicsgreenhouse.com/cart/32340856242270:1?attributes[eftid]=123
As an easy solution, persisting the query parameters through the entire site to the checkout seems like an obvious solution, but I'm wondering if there's either a Shopify setting or app that allows this, or if I should be coding it myself.
If I can't persist the query parameters through, are there any storeable attributes that can be used on the frontend of the site before the cart (ie. product page), that is accessible on the Additional Scripts area of the Receipt. IE. using utm parameters in the URL and printing this URL parameters in additional scripts.
Thanks!
Your example only works as a direct permalink, the param does not persist in either direction
You need to consume the attributes as soon as they are present and store them in cart attributes or a cookie.
Use the ajax cart api update.js endpoint to for cart attributes https://shopify.dev/docs/themes/ajax-api/reference/cart#post-cart-update-js .
Optionally along with javascript window.location object and history to persist the url params in the users browser.
Further Additional Scripts is being depreciated, depending on merchants use case see the LittleData replacement guide
Save time & money ,Ask Questions The Smart Way
Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Buy Paul a ☕ Coffee for more answers or donate to eff.org
User | RANK |
---|---|
38 | |
24 | |
13 | |
11 | |
8 |
Transform this holiday season into a shopping spree. Plus, learn how to effortlessly open ...
By Jasonh Dec 8, 2023Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023