-
AuthorPosts
-
June 10, 2016 at 10:23 pm #646395
I have the correct code to add “Random” as a sorting option. It used to work for the product grid and show up. I just noticed now it doesn’t. Did something change? I did search this forum and found a thread for a while ago about editing a file to add Random in, but I’m looking for an update proof solution. Below is what I have and what was working for quite a while.
// adds an extra option for sorting product listings randomly add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' ); function custom_woocommerce_get_catalog_ordering_args( $args ) { $orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) ); if ( 'random_list' == $orderby_value ) { $args['orderby'] = 'rand'; $args['order'] = ''; $args['meta_key'] = ''; } return $args; } add_filter( 'woocommerce_default_catalog_orderby_options', 'custom_woocommerce_catalog_orderby' ); add_filter( 'woocommerce_catalog_orderby', 'custom_woocommerce_catalog_orderby' ); function custom_woocommerce_catalog_orderby( $sortby ) { $sortby['random_list'] = 'Random'; return $sortby; }
June 14, 2016 at 7:44 am #647826Hey Kahil!
Thank you for using Enfold.
If you’re using the product grid element, add this in the functions.php file:
add_filter('avia_product_slide_query', 'avia_product_slide_query_mod', 10, 2); function avia_product_slide_query_mod($params, $grid, $test) { $params['orderby'] = 'rand'; return $params; }
Cheers!
IsmaelAugust 27, 2017 at 9:44 am #844494Hi Ismael,
I was searching for a solution to get the Option “random” available to my product grid.
This filter, mentioned above, does not add the random Option to my product grid sorting Dropdown.
Is there another solution, or do I have to use the shortcode directly?Regards,
MichaelAugust 28, 2017 at 8:23 am #844717Hi,
I have noticied that you created this thread more than one year ago, so, ensure that you`re using our latest version of the theme and plugins and provide to us your WP credentials and website link if this issue persists.
Best regards,
John TorvikAugust 28, 2017 at 8:40 am #844725Hi John,
sorry, this was not my thread actually. But since here a solution for my current problem was provided, I replied to this thread!
Or should I open a new thread?Please feel free to log into my page.
Regards,
MichaelAugust 30, 2017 at 1:11 pm #845772Hi Michael,
Here is where the setting appears from the code above
http://imgur.com/a/k4lmWThe code works fine on my instance. SO you set it in WooCommerce settings and then choose it in the product grid setting.
If you need further assistance please let us know.
Best regards,
Victoria- This reply was modified 7 years, 2 months ago by Victoria.
August 30, 2017 at 2:52 pm #845820Hi Victoria,
thank you for your answer.
Yes, this Option is available now and I already saw and testet it. But changing this would influence all the product listings.
I want to get the Random Option only for a Special product grid, not for woocommerce product queries.Hopefully you can see my Problem now?
Best Regards,
MichaelAugust 30, 2017 at 6:50 pm #845915@zwachm I have been requesting that for a long time. The last time I asked, a nod told me that they weren’t responsible for and don’t support added code and offered me to buy their support time. As the code came from the team and is on their website as a snippet, I called them out in it. Been radio silence ever since. The random code seems to work fine the way you and I want it to IF you’re using it on portfolios and image galleries. But not for product grids. I know it is possible to do since they donl it with the related product and up sell listings on a single product page. So it can be done.
For me, the only way I could get it to work the way I wanted was to use the random code for the grid where I needed to, then when I needed to put things in a specific order I manually did each listing using the single product shortcode. Until they fix their code, that is the only way to do this.
August 30, 2017 at 8:32 pm #845952@Kahil: thank you for your Response!
I already have a solution for it, but it is a source Code Change in ENFOLD. So my Intention was to get it solved/added in the next update, since it IS NOT a big deal!!
With this Code Change you will have the Dropdown for the product grid Extended by the random Option:
File:
enfold/config-templatebuilder/avia-shortcodes/product_grid.phpsimply add the ‘random’=>’rand’,
"name" => __("Sorting Options", 'avia_framework' ), "desc" => __("Here you can choose how to sort the products. Default setting can be set at Woocommerce -> Setting "id" => "sort", "type" => "select", "std" => "dropdown", "no_first"=>true, "subtype" => array( __('Let user pick by displaying a dropdown with sort options (default value is defined at Defau __('Use defaut (defined at Woocommerce -> Settings -> Default product __('Sort alphabetically', 'avia_framework' ) =>'title', __('Sort by most recent', 'avia_framework' ) =>'date', __('Sort by price', 'avia_framework' ) =>'price', 'random'=>'rand', __('Sort by popularity', 'avia_framework' ) =>'popularity')),
- This reply was modified 7 years, 2 months ago by zwachm.
September 3, 2017 at 6:00 pm #847419 -
AuthorPosts
- You must be logged in to reply to this topic.