For discussing the development and usage of Checkout UI extensions, post-purchase extensions, web pixels, Customer Accounts UI extensions, and POS UI extensions
We are trying to migrate from our own injected ScriptTag to the Web Pixel. In our current implementation, we are able ensure a discount code is applied by making a request to `https://{store}.myshopify.com/discount/{code}`. When you are in the checkout page the code will be applied.
However, when using the Web Pixel, that same request throws the following error:
`RestrictedUrlError: Request are not allowed to the same origin`.
Is there a workaround for this? Or is this intended behavior? We need this functionality for our app.
Hi Daniel,
Instead of directly making a request to apply the discount code, you can use the Checkout API to apply the discount code programmatically. Using the Checkout API, you can create a new checkout, add items, and apply a discount code with the `applied_discount` property.
Hope this helps!
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog