What you'd want to do is flip your property usage. Rather than having a discounted price, have a "Pre Discount Price" and always store the price you want to charge in the price field.
In your code you can then say, if there is a Pre Discount Price, assume the product is on sale and the price in the price field has been discounted, but if the Pre Discount Price field is empty, then the item isn't discounted and you can show your regular, non discount UI.
You can have 2 properties, but not the two you are wanting. Like I say, rather than Price and Discounted Price, you'd instead have Price which holds the current price you want to charge (so if you don't have a discount, it is the un-discounted price, but if you do have a discount, it's the discounted price) and something like Discounted From Price which can hold some value for what the price of the product was before discount.
In your front end code then you can check to see if Discounted From Price has a value and if it does, you know it's discounted so you can do similar view logic.
A common output would be to show the pre-discount price with a strikethrough which would have code something like:
Matt.... I just realized that I was struck by a brainfart. I flipped the logic around and wanted TC to use the discounted price INSTEAD of the Price attribute.... Your example makes perfect sense and it's actually what I already use.
What basically confused me was the UI which was flipped around which resulted in the opposite result I wanted.
Using discount price on product
Hey lads!
I have a working shop where I would like to use the "discounted" price. However, I can't seem to get that working.
Here's an example:
https://roldskovcykelshop.dk/olie-pleje-energi/pleje-vedligeholdelse/muc-off-dry-lube-120-ml/
The way I have made it is pretty simple:
I'm wondering how I can trigger the shop to use the discounted price?
// Mike
Hey Mike,
What you'd want to do is flip your property usage. Rather than having a discounted price, have a "Pre Discount Price" and always store the price you want to charge in the
price
field.In your code you can then say, if there is a Pre Discount Price, assume the product is on sale and the price in the price field has been discounted, but if the Pre Discount Price field is empty, then the item isn't discounted and you can show your regular, non discount UI.
Hope that helps
Matt
Hi Matt,
So if I understand you correctly. I cannot have two properties in my backend for each product:
Price (actual prize): 400
Discount price: (This is the new price if I enter something in here) 300
And in my code check if the Discount Price exists, then tell TeaCommerce to use that Discount Price as the actual price?
I understand your explanation as it HAS to be the price-property that TeaCommerce use?
I'm not sure if this makes any sense.
Hey Mike,
You can have 2 properties, but not the two you are wanting. Like I say, rather than Price and Discounted Price, you'd instead have Price which holds the current price you want to charge (so if you don't have a discount, it is the un-discounted price, but if you do have a discount, it's the discounted price) and something like Discounted From Price which can hold some value for what the price of the product was before discount.
In your front end code then you can check to see if Discounted From Price has a value and if it does, you know it's discounted so you can do similar view logic.
A common output would be to show the pre-discount price with a strikethrough which would have code something like:
By doing it this way, the price that TC will charge is always in the
price
field regardless so TC will know what to charge.Matt.... I just realized that I was struck by a brainfart. I flipped the logic around and wanted TC to use the discounted price INSTEAD of the Price attribute.... Your example makes perfect sense and it's actually what I already use.
What basically confused me was the UI which was flipped around which resulted in the opposite result I wanted.
Thank you Matt, for your everlasting patience.
// Mike
Hey Mike,
You are more than welcome. I'm glad you were able to get things working 👍
Matt
is working on a reply...