Sort grouped products by menu order

Fixes #14665
This commit is contained in:
Mike Jolley 2017-04-25 12:08:17 +01:00
parent 6afc566de4
commit 763c8e8018
1 changed files with 11 additions and 5 deletions

View File

@ -972,11 +972,17 @@ if ( ! function_exists( 'woocommerce_grouped_add_to_cart' ) ) {
function woocommerce_grouped_add_to_cart() {
global $product;
wc_get_template( 'single-product/add-to-cart/grouped.php', array(
'grouped_product' => $product,
'grouped_products' => array_map( 'wc_get_product', $product->get_children() ),
'quantites_required' => false,
) );
$products = array_filter( array_map( 'wc_get_product', $product->get_children() ) );
if ( $products ) {
usort( $products, 'wc_products_array_orderby_menu_order' );
wc_get_template( 'single-product/add-to-cart/grouped.php', array(
'grouped_product' => $product,
'grouped_products' => $products,
'quantites_required' => false,
) );
}
}
}
if ( ! function_exists( 'woocommerce_variable_add_to_cart' ) ) {