I want to be able to show sale prices on the collection and product pages for items in a certain collection without using the “Compare at” price, which requires that I manually change the price and add a compare at price to every individual item. I figured out a way to do what I want by modifying the price.liquid file under Snippets. I replaced this bit of code:
assign compare_at_price = target.compare_at_price
assign price = target.price | default: 1999
with this:
assign compare_at_price = target.price
assign price = target.price | minus: 2000 | default: 1999
This is great, it shows the original price, which is crossed off, and the new sale price, which is $20 off the original cost. It’s exactly what I want, however I only want the discount to apply to specific products.
I created a saleprice.liquid snippet that copies the original price.liquid snippet and includes the modified code. I created a new custom-product.liquid file under Sections and a new custom-product.json file under Templates that references the custom-product.liquid file. All products I’d like to place on sale reference this custom-product.json file. The question I have is, where in either the custom-product.liquid or custom-product.json files is the price.liquid file referenced? I tried changing this part of the custom-product.json code:
“price”: {
“type”: “price”,
“settings”: {
to
“price”: {
“type”: “saleprice”,
“settings”: {
but, I get the following error:
Unable to update the file
- Invalid value for type in block ‘price’. Type must be defined in schema.
I’ve been messing around in the code for a while, but I’m not really sure what I’m doing or what I should be looking for. Help please!