Reading the cart.id to pass as a parameter in a tag

Highlighted
Tourist
10 0 7

Hello,

I am putting some tags on my website for tracking (not facebook Pixel, Bing or GA!) and one of the parameters i need to pass through is the cart id from a user session. 

I am familiar with the liquid variables and have being using them for the rest of the tags but there does not seem to be a liquid tag available for a cart id.

My question is - Is there a way of extracting a cart ID from a user session? in order for it to be passed as a parameter 

Many Thanks

0 Likes
Highlighted
Shopify Expert
539 24 110

You can extract the checkout ID from the URL with Javascript.

★ ThemeUp: Nifty Upgrades for your Shopify Store ★ https://themeup.net
0 Likes
Highlighted
Tourist
10 0 7

Thanks Thomas,

Is a cart id only assigned once the checkout procedure has begun?

Is there a way you get a cart id of a cart which has not begun the checkout process, i.e just adding items onto the cart?

0 Likes
Highlighted
Shopify Expert
539 24 110

I'm not sure, but I think the ID is assigned the first time a cart gets submitted to checkout. Which would make sense, as the ID wouldn't be needed before then and assigning one to every cart even before going to checkout would result in tons of useless IDs being generated.

★ ThemeUp: Nifty Upgrades for your Shopify Store ★ https://themeup.net
0 Likes
Highlighted
Tourist
10 0 7

Makes sense.

The URL for my checkout is the following

https://beautyandseoul.co.uk/15334581/checkouts/57dsg2a5hfgd3774f2d446b80f7cf005a

I'm assuming the ID is 15334581 as this is consistent with the ID on the abandoned baskets page. Is this correct?

Cheers for your help, really appreciated

0 Likes
Highlighted
Shopify Expert
539 24 110

The number before /checkouts/ is the store ID and is the same for every ckeckout. The longer alphanumeric string after /checkouts/ is the checkout ID. 

★ ThemeUp: Nifty Upgrades for your Shopify Store ★ https://themeup.net
1 Like
Highlighted
Tourist
7 0 0

I'm trying to display an id to the active customer on the cart screen, but preferably an easier one than is shown in the URL.

I would like the customer to be able to call us on the phone while on the website and tell us the id, we could then look at the cart items on our end and assist the customer with any questions.

Any suggestions?

0 Likes
Highlighted
Shopify Partner
2151 101 303

@ogeid nothing that's really going to be natively supported.

Frontend

You could try using line item properties, cart.note or cart.attributes so a keyword|phrase|slug|product-handle is on a hidden line item or the cart? 

/cart/update?attributes[supportcode]=emptywalrusaction

Can't really use in the url since the param will just resolve to a clean url or redirect, though maybe a redirect with a param might keep it visible?

Abandonded cart doesn't seem to search those fields  though only higher level entries like product title,etc.

Not tested if this is an immediate limitation or if shopify indexes after awhile and then becomes searchable

 

You will need to come up with a word generation scheme to avoid collisions which is the point of the checkout ID in the first place similar.

If trying to transform the checkout.id to human friendly phrase then you'd still have to work out the mapping between a customers identity "phrase" and the actual ID...

Like gfycat does combining from wordlists - adjective adjective animal (https://gfycat.com/accomplisheduntriedlacewing)

for performance you'd want an app to generate these hashwords and not on the customers browser but i've yet to see a library for the front end only the backend

https://github.com/jjt/hashwords


Backend

THEN also have that mapping useable by your support to find the actual checkout.ID 

Of course none of this applies if your using a separate app that doesn't a facilitate this.

You can pull the info from https://shopify.com/admin/checkouts.json though remember pagination so try to filter such lists first.

Advanced is to make a browser extension|bookmarklet that fetches the cart.note or cart.attribute and displays it in the abandoned checkouts list so you can find it with ctrl+f.

or manually ctrl+f in the json for the customers support-phrase, get the related checkout.id then search in the list,

or just get the abandoned.id number and append it to /checkouts/1234567890 

there are also open source json viewer browser extensions that could be made to make the abandoned-checkout.ids clickable links too.

 

Problem Solved? ✔️Accept and ? Like the solution so you can help others.
Buy me a coffee ☕ paypal.me/paulnewton or donate to eff.org
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
0 Likes