Home / Forums / WoodMart support forum / Query parameter
Home › Forums › WoodMart support forum › Query parameter
Query parameter
- This topic has 7 replies, 2 voices, and was last updated 2 years, 3 months ago by
Aizaz Imtiaz Awan.
-
AuthorPosts
-
April 4, 2024 at 7:41 pm #555011
JonatasParticipantI would like to know how I can have a query parameter for “Product Tags” New (New). For example, I have a query parameter https://davyjones.com.br/?s=Gola%20O&post_type=product, which filters the products entered in the “Gola O” category.
April 5, 2024 at 12:42 pm #555167Hello,
Sorry to say but we didn’t seem to understand your concern properly. Could you please elaborate on your concern more with some useful Screenshots so that we can better understand and assist you accordingly or share some examples of what you actually want.
Best Regards.
April 5, 2024 at 3:19 pm #555230
JonatasParticipantI’ll explain better, I would like to know if the theme offers support so I can filter
only the products that have the “new” label in their image, but I would like to know if it is possible to get this information through url parameters, as I had mentioned in the previous message this url https://davyjones.com.br/?s= Gola%20O&post_type=product can only filter products from the “Gola O” category using the URL parameter ?s=Gola%20O&post_type=product, I sent the images so you can understand better.Attachments:
You must be logged in to view attached files.April 5, 2024 at 6:27 pm #555295Hello,
Define the code below in the functions.php file in your child theme. You can sort the new label in the sorting option of the shop page.
https://ibb.co/2g7k4QXfunction 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 'new_label': $sort_args['orderby'] = 'meta_value'; // Sort by meta_value because we’re using alphabetic sorting $sort_args['order'] = 'asc'; $sort_args['meta_key'] = '_woodmart_new_label'; // 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['new_label'] = __( 'New Label', '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' );Best Regards.
April 5, 2024 at 8:49 pm #555304
JonatasParticipantI inserted your code but it is displaying only the parent products, as my products are variables and I use the WooCommerce Single Variations plugin, so I need this code to display only the product variations instead of showing only the parent products.
April 6, 2024 at 10:23 am #555354Hello,
Please try to remove the precious code and add the code below in the functions.php file in your child theme.
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 ) { case 'new_label': $sort_args['orderby'] = 'meta_value'; $sort_args['order'] = 'asc'; $sort_args['meta_key'] = '_woodmart_new_label'; $sort_args['orderby'] = 'meta_value_num'; // Adjust the meta key to match the one used for product variations $sort_args['meta_query'] = array( array( 'key' => '_variation_id', // Use _variation_id to target product variations 'compare' => 'EXISTS', // Ensure that variations exist ) ); break; } return $sort_args; } add_filter( 'woocommerce_get_catalog_ordering_args', 'skyverge_add_postmeta_ordering_args' ); function skyverge_add_new_postmeta_orderby( $sortby ) { $sortby['new_label'] = __( 'New Label', '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' );Best Regards.
April 8, 2024 at 9:46 pm #555791
JonatasParticipantUnfortunately this code didn’t work, it has the same behavior as the previous code
April 9, 2024 at 1:59 pm #556020Hello,
Sorry but there is no option in Theme Settings available for that. It requires customizations and this is beyond our limitations and support policy.
Try to find a plugin for this purpose. We have not tested such kinds of plugins, so we don’t have any detailed suggestions.
Best Regards.
-
AuthorPosts
- You must be logged in to create new topics. Login / Register