How do I apply a coupon via URL + redirect WITH query parameters in the redirect url?

abro
Shopify Partner
2 0 2

Hi everyone,

 

I know you can apply a coupon and redirect to the product page using the following structure:

https://myshopifystore.com/discount/MYDISCOUNTCODE?redirect=/products/my-product-page 

The problem I'm facing is that I also need to pass my product page some query parameters but when I include the query parameters in the redirect url, it basically gets stripped away once it redirects.  In otherwords, this redirects, but doesn't pass the query parameter called 'myparam' to my-product-page once it redirects:

 

https://myshopifystore.com/discount/MYDISCOUNTCODE?redirect=/products/my-product-page?myparam=myvalue

Anyone know what I'm doing wrong or how I can achieve this?  Thanks!

Replies 2 (2)

abro
Shopify Partner
2 0 2

@Shopify do you guys have anyone on your dev team that can assist with this?

RhiRo
Shopify Partner
41 3 7

Hey! 
Don't know if you still need this (or at least someone else might) but I believe the solution is to prepend the parameters with & instead of ?This is because you are already adding a parameter with the redirect part.

So instead of 

https://myshopifystore.com/discount/MYDISCOUNTCODE?redirect=/products/my-product-page?myparam=myvalue

It would be 
https://myshopifystore.com/discount/MYDISCOUNTCODE?redirect=/products/my-product-page&myparam=myvalue

The resulting url after the redirect is
https://myshopifystore.com/products/my-product-page?myparam=myvalue

I discovered this by accident because we were trying to do 
https://myshopifystore.com/discount/MYDISCOUNTCODE?redirect=/products/my-product-page?myparam=myvalue&myparam2=myvalue2 and only the second parameter was coming through to the final url. 

Hope that helps 🙂