I can't get sale_start_date or sale_end_date to work in expresso store.

The following code (inside {exp:store_product})

{if on_sale}
<strong>På salg: <strike>{regular_price}</strike> {price}</strong><br>
<em>Du sparer {you_save}</em><br>
<em>Salget varer til {sale_end_date format="%m-%d-%Y"}</em>
<strong>Pris: {price}</strong>

simply outputs {sale_end_date format="%m-%d-%Y"} as plain text exactly as is. It doesn't seem to be a recognized tag. All other tags seem to work.

What am I doing wrong? I can't see anything else in the docs.

  • What version of Store and EE are you using? – Justin Long Jun 30 '14 at 13:33
  • Store 2.3.1 and EE 2.8.1 – Stian Karlsen Jun 30 '14 at 17:43
  • What happens if you output {sale_end_date} without the formatting param? – Nathan Pitman Jul 1 '14 at 8:39
  • Same result. Outputs as plain text. – Stian Karlsen Jul 1 '14 at 9:22

It appears this variable never made it into Store 2 even though it is in the docs. Email support and we will take a look and getting this fixed.

** Edit v2.3 doesn't have this variable for a reason. With Store 2 you can have multiple sales per product, so there is no single variable that would work. We will need to add a new feature in an upcoming version to make it work.

| improve this answer | |
  • Also ran into this now and can see there isn't actually an attribute like sale_start_date or sale_end_date parsed in the Product.toTagArray() function. Can understand why this is difficult to achieve, because products and sales are completely separate so that a product can belong to any discounts or sales. Maybe in the mean time it can be removed from the docs, because it is obviously incorrect. – jpunk11 Jan 13 '15 at 11:57

This is probably not the best solution, because it will just use the last sale's start and end date if there's multiple sales and discounts, but it is better than nothing and most sites will only run one sale at a time.

In store/src/Store/Service/ProductsService.php just below the line (+- line 248)

$product->on_sale = true;


// HACK: added sale start and end date
$product->sale_start_date = isset($sale['start_date']) ? $sale['start_date'] : NULL;
$product->sale_end_date = isset($sale['end_date']) ? $sale['end_date'] : NULL;
| improve this answer | |

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.