Vendorshop – sort products by EventDate

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WC Marketplace Vendorshop – sort products by EventDate

Viewing 4 reply threads
  • Author
    Posts
    • #135768
      Nico Bein
      Participant

      Hey!

      I want to sell tickets via FooEvents and the marketplace. I customized the vendor shop page with Elementor Pro:
      https://drive.google.com/open?id=1abGwDKA2sxzlRZGUSSCdp7P0LAf8QV2-

      Now I need to sort the products by the event date (WooCommerceEventsDate). How can I do that?

      Best,
      Nico

      Attachments:
      You must be logged in to view attached files.
    • #135860

      Hello,

      Actually this products section in “vendor store page” is use WooCommerce Shop page template. So, this is basically the FooEvent Plugin additional feature.
      Try this code to your child theme’s functions.php
      In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/

      function skyverge_add_postmeta_ordering_args( $sort_args ) {
          
        $orderby_value = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
        switch( $orderby_value ) {
        
          // Name your sortby key whatever you'd like; must correspond to the $sortby in the next function
          case 'eventdate':
            $sort_args['orderby']  = 'meta_value';
            // Sort by meta_value because we're using alphabetic sorting
            $sort_args['order']    = 'asc';
            $sort_args['meta_key'] = 'WooCommerceEventsDateTimestamp';
            // use the meta key you've set for your custom field, i.e., something like "location" or "_wholesale_price"
            break;
              
        
          
        }
        
        return $sort_args;
      }
      add_filter( 'woocommerce_get_catalog_ordering_args', 'skyverge_add_postmeta_ordering_args' );
      
      // Add these new sorting arguments to the sortby options on the frontend
      function skyverge_add_new_postmeta_orderby( $sortby ) {
        
        // Adjust the text as desired
        $sortby['eventdate'] = __( 'Sort by Event Date', 'woocommerce' );
          
        return $sortby;
      }
      add_filter( 'woocommerce_default_catalog_orderby_options', 'skyverge_add_new_postmeta_orderby' );
      add_filter( 'woocommerce_catalog_orderby', 'skyverge_add_new_postmeta_orderby' );

      Ref: https://gist.github.com/bekarice/0df2b2d54d6ac8076f84

      Thanks.

    • #135959
      Nico Bein
      Participant

      Thanks, but actually that doesn’t help.

      I need to add a query ID on the shop page to filter it like that:

      add_action('elementor/query/ft_event_listing', function($query){	
      	$query->set('orderby', 'meta_value');
      	$query->set('meta_key', 'WooCommerceEventDate');
      	$query->set('order', 'ASC');
      });

      It would be great if it would be possible to easily add the ID in the Elementor widget settings (as seen on other plugins). Since that is not possible: Where may I add the ID?

      Best,
      Nico

    • #135966

      Hello,

      Sorry, but we don’t understand “add a query ID” means.
      Can you tell us from where you are using this “elementor/query/ft_event_listing” action? Have you added any custom code for this?
      Are you not using “WCFM – WCFM Marketplace integrate Elementor”(https://wordpress.org/plugins/wc-frontend-manager-elementor/) plugin for setup vendor store page?
      We have “WCFM – WCFM Marketplace integrate Elementor” plugin to setup Vendor store page using Elementor.

      Thanks.

    • #135968
      Nico Bein
      Participant

      The code above is from a project WITHOUT vendors, WCFM and stuff. There I can use Elementor Pro’s “Posts” widget and either use the built-in filter options or give the query an ID and filter it via code in the functions.php (see https://developers.elementor.com/custom-query-filter/).

      Now I use the marketplace and also “WCFM – WCFM Marketplace integrate Elementor” plugin. I created a store page with Elementor Pro and added the “Store Tab Contents” widget from the “WCFM – WCFM Marketplace integrate Elementor” plugin. It works and only the vendor’s products are shown. But I want this query to be sorted by a special field (in my case ‘WooCommerceEventsDate’) and I need the expired events to be hidden.

      I only know the way to do that like mentioned in the first paragraph and I hoped that it would be possible to give the query created by the “Store Tab Contents” widget a custom ID (like ft_event_listing) and then order it.

      What would be the best way to do that?

      If there is no way with using the “Store Tab Contents” widget it might be possible the other way round…? Maybe I could use Elemetor Pro’s “Posts” widget, sort it the way I like, give it an ID (e.g. ft_event_listing) and have a function to only display the vendor’s products…?

Viewing 4 reply threads
  • You must be logged in to reply to this topic.