[Resolved] off topic Woocommerce sort advice

Home Forums Support [Resolved] off topic Woocommerce sort advice

Home Forums Support off topic Woocommerce sort advice

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1029460
    Cheryl

    Hello,

    Were using GP, along with Woocommerce, ACF, membership, and subscriptions, and using it to sale events, so I’ve added some custom fields [date] and using a snipptet to sort in date order, so far so go, however, I’m having to try to get it to sort so that it only shows today’s events and future events, any advice or pointing in the right direction would be appreciated.

    Regards

    Cheryl

    add_filter('woocommerce_get_catalog_ordering_args', 'woocommerce_get_custom_ordering_args');
    function woocommerce_get_custom_ordering_args( $args ) {
    $args['order'] = 'ASC';
    $args['meta_key'] = 'event_date';
    $args['orderby'] = 'meta_value_num';
    return $args;
    }
    #1029477
    David
    Staff
    Customer Support

    Hi there,

    maybe this will be of use:

    https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters

    In particular the meta_compare argument. So could compare the meta_value with the current date.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.