Searching for all items that are on sale, as of Express Store 2.0.4, is currently MIA, despite the presence of the search:on_sale
parameter in the docs. That is, this code...
{exp:store:search channel="products" search:on_sale="yes"}
{title}
{/exp:store:search}
... returns all items in the products channel, not just products on sale.
You can hack around this by using looping through all products and checking each one using the on_sale
conditional:
{exp:channel:entries channel="products" orderby="title" sort="asc" disable="member_data|pagination" limit="99"}
{exp:store:product entry_id="{entry_id}" disable_form="yes" disable_javascript="yes"}
{if on_sale}
{title}
{/if}
{/exp:store:product}
{/exp:channel:entries}
But has anyone figured out how to display a Sorry, no items are currently on sale message when no items are on sale? I've tried a PHP (input), PHP (output), and a variety of Stash syntax. Something very strange is happening either with parse order or the way that on_sale
works. For example, you would think this would work:
{exp:channel:entries channel="products" orderby="title" sort="asc" disable="member_data|pagination" limit="99"}
{exp:store:product entry_id="{entry_id}" disable_form="yes" disable_javascript="yes"}
{if on_sale}
{exp:stash:set_value name="sale_items_exist" value="true"}
{title}
{/if}
{/exp:store:product}
{/exp:channel:entries}
{if "{exp:stash:get name='sale_items_exist' process='end'}" != "true"}
<p>Sorry, no items are currently on sale</p>
{/if}
<p>Debug: the stash variable is {exp:stash:get name='sale_items_exist' process='end'}</p>
When I use that code, if there is an item on sale, that last line outputs nothing (and so my "no items on sale" message shows up even though it shouldn't). Somehow Stash is not setting sale_items_exist
to true
.
Has anyone solved this problem some other way?