App reviews, troubleshooting, and recommendations
Hello
I am working on building a theme for my client. The store has lots of discount codes across different products which are applicable to all the customers unconditionally. The requirement here is to show the discount codes applicable for a specific product on the product page, or atleast in a seperate offers page.
Is there any way to get the applicable discount codes for a products within the theme?
Thanks
Hey folks! I think I may have a workaround for this request 🙂
It would be possible to display each individual discount code on the product page by using metafields. The general process would be to assign the discount code as a metafield value to each individual product, and then use the metafield Liquid object to output the unique value/ discount code on each product page.
If you use this approach however, it’s important to remember that if a product’s discount code is changed, you’d need to manually update the discount metafield on the product level.
Here’s a description of the process:
{% if product.metafields.custom.discount != blank %}
<p>Use this discount for 30% off: {{ product.metafields.custom.discount }}</p>
{% endif %}
Hope this solution helps! You could also customize the look and feel with CSS, and potentially build this as its own block element. It would also be a great idea for an app developer to build this logic and workflow into an app!!
Cheers,
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
These are pretty cryptic instructions, or maybe I pay for Shopify so I don't have to code!! But what or where is "product editing page that is associated with the discount"? I have each product page set up for discount, but don't see any new meta field. How do I enter the "logic" and maybe more detail can be shared as to the full logic argument coded and where. Again, sorry if I'm slow or something. I shouldn't have to be doing this coding at all, but any help would be appreciated.
I want to offer a solution!
I was able to set a % or fixed discount from the DISCOUNT section in Shopify Admin. You can apply this to 1 or as many collections as need more. You could also apply this to specific products individually I think. Title the discount name with the % or fixed amount you want to offer, this way you can keep track of what it is used for.
Next, I added tags to the associated products you want to discount, you can do this in bulk by filtering by collection in the PRODUCTS section. The tags could be DISOUNT-5% or similar.
Then on the products page you can add logic, IF PRODUCT.TAGS CONTAIN DISCOUNT-5% THEN... add your logic to display discounts. I simply did the current price * percent discount to output my results. See below!
Here is my output that I came up with:
Please reach out if you want any other help on this or have any suggestions/ recommendations!
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023