Sort Product Categories by 'Menu Order" in the Product Categories Widget in Elementor Pro #29581
mtorrance
started this conversation in
Feature Request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Prerequisites
What problem is your feature request going to solve? Please describe..
In the 'order by’ menu of the Product Category widget in Elementor Pro there isn’t the ability to sort the categories by ‘menu_order’ which is the order that the user creates in the Product Categories editor in WooCommerce when dragging them around. Some of my sites have hundreds of categories and a lot of time is spent organizing them for it to be ignored by the Product Categories widget.
Currently users have to add something like this to functions.php
—>
function inject_menu_order_controls( $element, $args ) {
$elementor = \ElementorPro\Plugin::elementor();
$control_data = $elementor->controls_manager->get_control_from_stack( 'wc-categories', 'orderby' );
$control_data['options']['menu_order'] = esc_html__( 'Menu Order', 'elementor-pro' );
$element->update_control('orderby', [ 'options' => $control_data['options'] ]);
}
add_action( 'elementor/element/wc-categories/section_filter/before_section_end', 'inject_menu_order_controls', 30, 2 );
<—
but if you just add this one line of code to line 157 of categories.php (plugins/elementor-pro/modules/woocommerce/widgets/categories.php) just after 'count’ then it would be available without have to modify functions.php.
'menu_order' =>esc_html__( 'Menu Order', 'elementor-pro' ),
This has been tested and works in the current public release.
Describe the solution you'd like.
Being able to select "Menu Order" from the "Order by" menu in the Elementor Pro Product Categories widget which currently only has Name, Slug, Description and count without the need to edit the functions.php file.
Describe alternatives you've considered.
Currently users have to add something like this to functions.php
—>
function inject_menu_order_controls( $element, $args ) {
$elementor = \ElementorPro\Plugin::elementor();
$control_data = $elementor->controls_manager->get_control_from_stack( 'wc-categories', 'orderby' );
$control_data['options']['menu_order'] = esc_html__( 'Menu Order', 'elementor-pro' );
$element->update_control('orderby', [ 'options' => $control_data['options'] ]);
}
add_action( 'elementor/element/wc-categories/section_filter/before_section_end', 'inject_menu_order_controls', 30, 2 );
<—
Additional context
No response
Agreement
Beta Was this translation helpful? Give feedback.
All reactions