Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WC Marketplace › Vendorshop – sort products by EventDate
- This topic has 4 replies, 2 voices, and was last updated 4 years, 6 months ago by Nico Bein.
- AuthorPosts
- May 27, 2020 at 5:34 pm #135768Nico BeinParticipant
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,
NicoAttachments:
You must be logged in to view attached files. - May 27, 2020 at 7:27 pm #135860Sarmistha ChakrabortyMember
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.
- May 27, 2020 at 10:56 pm #135959Nico BeinParticipant
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 - May 27, 2020 at 11:12 pm #135966Sarmistha ChakrabortyMember
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.
- May 27, 2020 at 11:54 pm #135968Nico BeinParticipant
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…?
- AuthorPosts
- You must be logged in to reply to this topic.