Forum
Filtering between two dates; Shop
I'm building a site using Perch Shop in Runway to sell training courses. I've added some extra fields into the product template including date. My main shop page shows a list of products, and I want to filter this by the date field, to show courses in the next month.
In my page template, for the list display, I've got:
// List mode
$today = date('Y-m-d');
$future_date = date('Y-m-d',mktime(0, 0, 0, date("m")+1, date("d"), date("Y"))); // 1 month forward
echo $today . "<br>"; // for testing only; comment out on live site
echo $future_date . "<br>"; // for testing only; comment out on live site
perch_shop_products(array(
'template' => 'products/list.html',
'filter' => 'date',
'match' => 'between',
'value' => $today, $future_date,
'sort' => 'date',
'sort-order' => 'ASC',
));
I'm calculating the future date as today's date plus 1 month and then filtering on the date field for dates between $today and $future_date. It displays nothing, although I've got a few courses that match that filter. Debug shows no errors.
Filtering by just one of the date criteria (e.g greater than $today; less than $future_date) appears to be working correctly and displaying the appropriate courses - tested by changing some course dates and checking they're displayed correctly.
What do I need in order to filter between 2 dates?
Diagnostics:
Summary information
Perch Runway: 2.8.34, PHP: 5.5.12, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: bf9ad53b11c9a57efdb1057292d73b928b8c5c77 $, with PDO
Server OS: WINNT, apache2handler
Installed apps: content (2.8.34), assets (2.8.34), categories (2.8.34), perch_blog (5.0), perch_events (1.9.3), perch_forms (1.8.3), perch_gallery (2.8.6), interact_orders (1), perch_shop_orders (1.0.10), perch_shop_products (1.0.10), my_sample (2.1), perch_shop (1.0.10), perch_members (1.5)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_gallery', 'perch_forms', 'perch_events', 'perch_members', 'perch_shop', );
PERCH_LOGINPATH: /cms
PERCH_PATH: C:\wamp\www\northern\cms
PERCH_CORE: C:\wamp\www\northern\cms\core
PERCH_RESFILEPATH: C:\wamp\www\northern\cms\resources
Image manipulation: GD
PHP limits: Max upload 64M, Max POST 50M, Memory: 1024M, Total max file upload: 50M
F1: 6a33f95eca3667f9e0c39bf5ca2980fe
Resource folder writeable: Yes
HTTP_HOST: northern.local
DOCUMENT_ROOT: C:/wamp/www/northern
REQUEST_URI: /cms/core/settings/diagnostics/
SCRIPT_NAME: /cms/core/settings/diagnostics/index.php
This:
needs to be:
Fantastic. Knew it had to be ridiculously simple! Thanks for replying at the speed of light!