2

Is it possible to still show that an item is on sale while using the dynamic product variable for store_product_price?

Here is what I am trying to do:

{if on_sale}{regular_price}{sale_price}{if:else}{price}{/if}

When I use the above code, it ONLY shows the sale price, but I'd still like it to show the regular price crossed out.

Am I missing something?

2

You should be able to do something along the lines of:

{if on_sale}
  Price: <del>{regular_price}</del> 
  {price}.
{if:else}
   Price: {price}
{/if}

EDIT 1:

If you want to use the dynamic price variables you would need to do something slightly different in this case then putting the css class on the h2 element. Something along the lines of this to only show the regular price if the item is on sale.

<h2> 
  Price: {if on_sale}<del>{regular_price}</del>{/if} 
  <span class="store_product_price">{price}</span>.   
</h2>
| improve this answer | |
  • Hi Justin. That is what I am doing now, but it only shows the sale price, never the regular crossed out. Here is exactly what I have in my template... <h2 class="store_product_price"> {if on_sale}Price: <del>{regular_price}</del> {price}. {if:else} Price: {price} {/if} </h2> – Danielle LeComte Nov 8 '13 at 22:26
  • Aww sorry I somehow missed the you were using the dynamic variables (rereading the initial question I am not quite sure how I did that. The short answer is if you want to show both sale and regular price you can't use the dynamic variable. – Justin Long Nov 9 '13 at 0:21
  • The content that you enter inside of whatever element you put as the dynamic variable is a fallback when CSS/JS are disabled and under most circumstances won't be displayed to the user. – Justin Long Nov 9 '13 at 7:03
  • Is there a work around? I'd still like the price to dynamically update AND show that the items in on sale. Thx Justin. – Danielle LeComte Nov 10 '13 at 20:34
  • The only work around that I know of at the moment would be to use something similar to the code under Edit 1 or for you to extend the store js to also handle sale price. – Justin Long Nov 11 '13 at 5:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.