Automatically applied discounts for Buy Button

Daniel_Smith7
Shopify Partner
3 0 0

Does anyone know of a way to modify the embed code of the Buy Button to automatically apply a discount code?

0 Likes
Benjamin_C
Shopify Staff
Shopify Staff
368 0 42

Hello Daniel, Ben here - your Shopify Guru! 

  You can set the product on sale in your Shopify admin using the compare price. You cannot edit the code to automatically apply a discount because this would be a security issue. If this was possible anyone could reproduce your code and apply discounts automatically to your products, which would not be an ideal situation. 

If you set the product on sale in your Shopify admin it will show the sale price in the buy button as well.

I hope this helps! Feel free to reach out if you have any further questions :)

Cheers,
Ben C - Shopify Guru
Support@Shopify.com

0 Likes
Daniel_Smith7
Shopify Partner
3 0 0

The issue is that we use coupon codes to handle campaign attribution. We have hundreds of campaigns running at any given time running with different prices so this solution wouldn't work.  We use an approach similar to the permalinks to pre-load the cart method for our landing pages currently. I'm looking for something like this but the Buy Button so that we can stop using our custom Buy Button.

Example: /cart/VARIANTID:QUANTITY?discount=DISCOUNTCODE

 

Below is the custom solution I wrote to handle our needs. It works just the way we want but it isn't a scalable solution right now. I'm trying to avoid writing our own button generator and I was hoping to use the Buy Button provided by Shopify.

http://promo.vanityplanet.com/ig

 

0 Likes
Emilien_Klein
New Member
12 0 0

We would also like to be able to put the discount code in an URL, so that the discount is automatically applied to the cart. It doesn't necessarily need to be in a buy button URL, we would also want to use that to direct the users directly to the store's homepage and have that discount applied to whatever they end up purchasing, so I've created a separate thread on the forum.

0 Likes
Daniel_Smith7
Shopify Partner
3 0 0

Emilien,

There are a couple solutions you may want to look at. 

Another thread has documented the steps a developer needs to take to modify a theme to auto apply the discount the way you have described. Ultimately we ended up doing this after using an app for a while. We needed a little more flexibility around the way this was displayed on the cart page. What is still an issue is that the discounted total is not available at the cart page because the discount isn't applied until checkout. As a work around for now, we simply have a message explaining this to customers.

https://ecommerce.shopify.com/c/shopify-discussion/t/autofill-discount-via-url-a-step-by-step-walkth...

https://apps.shopify.com/autofill-discount-from-url

 

0 Likes
Emilien_Klein
New Member
12 0 0

Thanks Daniel, the first link you sent looks to be what I'm looking for. Off to implement that now!

0 Likes
Chris_Taylor1
New Member
2 0 0

What if it was an active coupon code that it applied, not a direct discount of the product?  Can this be done?  Then it can be easily controlled by the coupon settings.

0 Likes