Sort by date field

  • I'm having an issue with sorting products by date in perch shop. I have added a date field to product.html but sorting either ASC or DESC doesnt seem to work. I feel it is something to do with the way the date is formatted as they do take a certain order it just isn't that of ascending date!


    product.html:

    Code
    1. <perch:shop id="course_end_date" type="date" label="Course End Date" order="3" native required />

    product-card.html:

    product-list.php:

    PHP
    1. <?php
    2. perch_shop_products([
    3. 'template' => 'products/product-card.html',
    4. 'page' => '/index.php',
    5. 'sort' => 'course_end_date',
    6. 'sort-order' => 'DESC',
    7. 'sort-type' => 'numeric',
    8. ]);
    9. ?>
  • drewm

    Approved the thread.