Answer the question
In order to leave comments, you need to log in
How to sort products by SKU on order page in WooCommerce admin?
Good afternoon!
For faster assembly of orders, where the quantity of goods is more than 10 pcs. (goods in the warehouse are by Article) you need to sort the goods by Article on the order page in the admin panel.
Maybe someone has a suggestion to solve this issue.
Answer the question
In order to leave comments, you need to log in
Sort them in the basket, it will be written to the database in the right order:
function sort_cart_sku() {
$in_cart = array();
foreach ( WC()->cart->get_cart_contents() as $key => $item ) {
$in_cart[ $key ] = $item['data']->get_sku();
}
natsort( $in_cart );
$cart_items = array();
foreach ( $in_cart as $cart_key => $product_title ) {
$cart_items[ $cart_key ] = WC()->cart->cart_contents[ $cart_key ];
}
WC()->cart->cart_contents = $cart_items;
}
add_action( 'woocommerce_cart_loaded_from_session', 'sort_cart_sku' );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question