Ad

How To Add An Additional Value To A Shopify Checkout URL?

- 1 answer

My client's live Shopify setup has a feature where a URL goes to a sort of "quick checkout" that allows a customer to quickly purchase a single item. The way it works is, you first visit a URL like this:

https://site1.com/cart/xxxxxxxxxxx:y

and then you are immediately redirected to a URL like this:

https://www.site2.us/aaaaaaaa/checkouts/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

And then on that second URL you can fill out the checkout form to purchase a single item that is displayed there. Notice that the two URLs use a different domain name. The x's are numbers, the y is a number. The a's are numbers and the b's are hexadecimal digits(0-9, a-f).

Is this a common/documented URL flow for a Shopify single item checkout setup?

What I need to do is add a value to the first URL so that it carries through to the second URL, eg:

https://site1.com/cart/xxxxxxxxxxx:y/extra-val-herehttps://www.site2.us/aaaaaaaa/checkouts/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/extra-val-here

And then if the second URL has the extra value I need to do something extra in the code.

Ad

Answer

Shopify has some information on how to do this here: https://help.shopify.com/en/themes/customization/cart/use-permalinks-to-preload-cart#conversion-tracking

To summarize, you can add a cart note and an arbitrary number of cart attributes to your link as query parameters to the end of your direct-buy link.

The structure of such a URL is thus:

https://[yourstore.com]/cart/[variant_id]:[quantity]?attributes[extra-category-1]=extra-val-1&attributes[extra-category-2]=extra-val-2&note=Sure%20why%20not

I just confirmed that this does indeed work by placing a test order this way on my dev store - if you're still having any trouble, let me know and we can dig deeper.

Ad
source: stackoverflow.com
Ad