Forum
Filter PayPal Shop Products by Date
Hi, I'm setting up a simple PayPal Shop and was looking to filter the products by date, and ideally have them disappear (from the front-end) on the date entered.
I've created a date field in both product.html and product_in_list.html
<perch:shop id="productDate" type="date" time="true" label="Date/Time" format="l jS F Y @ g:ia" />
and I've tried to filter as below:
perch_shop_custom(array(
'template'=> 'shop/product_in_list.html',
'filter' => 'productDate',
'match' => 'gt',
'value' => date('l jS F Y @ g:ia'),
));
Without the value all the products appear, but with the value nothing appears.
Is it possible to filter by custom fields like this within the shop, or is there another way to achieve this sort of functionality?
I don't think the PayPal shop offers filtering on dynamic fields.
I think I've found a workaround…so I'll leave this here for anyone else that needs to do something similar.
I wondered if I could use <perch:if> within the product_in_list.html itself and then I found this post on the forum: How to compare a date field to today's date? (Which is essentially what I want to do.)
So I've added the set_var into my product listing page as below.
…and then this <perch:if> to the product_in_list.html template:
productDate is still:
Seems to work fine, and have just tested switching the date and time of the product earlier and later than now and it's filter as expected.