orders

Sorting order items by SKU in Woocommerce

对着背影说爱祢 提交于 2020-07-25 06:38:11
问题 I am trying to order the products by sku within an order in an email in Woocommerce . I have not had any luck with the following code. Some help? Thanks since now! add_filter( 'woocommerce_order_get_items', function( $items, $order ) { uasort( $items, function( $a, $b ) { return strnatcmp( $a['_sku'], $b['_sku'] ); } ); return $items; }, 10, 2 ); Sample sort result: INFSTRAW I NFMUFFIN INFFLORES INFTAFLOR INFTAPINK CTEPINK4 CTECAKE4 INFCHOCO UCUBTOMA 回答1: Updated On July 2020 Here is the way

Sorting order items by SKU in Woocommerce

◇◆丶佛笑我妖孽 提交于 2020-07-25 06:37:21
问题 I am trying to order the products by sku within an order in an email in Woocommerce . I have not had any luck with the following code. Some help? Thanks since now! add_filter( 'woocommerce_order_get_items', function( $items, $order ) { uasort( $items, function( $a, $b ) { return strnatcmp( $a['_sku'], $b['_sku'] ); } ); return $items; }, 10, 2 ); Sample sort result: INFSTRAW I NFMUFFIN INFFLORES INFTAFLOR INFTAPINK CTEPINK4 CTECAKE4 INFCHOCO UCUBTOMA 回答1: Updated On July 2020 Here is the way

Sort order items by SKU in Woocommerce admin order pages [duplicate]

落爺英雄遲暮 提交于 2020-07-23 07:39:29
问题 This question already has answers here : Sorting order items by SKU in Woocommerce (2 answers) Closed 4 days ago . I'm stumped if it's possible. I have scouted to only seeing results to sort by SKU on the front end. not the backend. When you edit an order, I want there to be an SKU column that I can sort by ASC/DESC . Is there a plugin out there that achieves this, or a snippet of code that can add in an additional column? Any help would be greatly appreciated. Below is an image illustrating

Sort order items by SKU in Woocommerce admin order pages [duplicate]

孤人 提交于 2020-07-23 07:38:19
问题 This question already has answers here : Sorting order items by SKU in Woocommerce (2 answers) Closed 4 days ago . I'm stumped if it's possible. I have scouted to only seeing results to sort by SKU on the front end. not the backend. When you edit an order, I want there to be an SKU column that I can sort by ASC/DESC . Is there a plugin out there that achieves this, or a snippet of code that can add in an additional column? Any help would be greatly appreciated. Below is an image illustrating

Sort order items by SKU in Woocommerce admin order pages [duplicate]

假如想象 提交于 2020-07-23 07:37:09
问题 This question already has answers here : Sorting order items by SKU in Woocommerce (2 answers) Closed 4 days ago . I'm stumped if it's possible. I have scouted to only seeing results to sort by SKU on the front end. not the backend. When you edit an order, I want there to be an SKU column that I can sort by ASC/DESC . Is there a plugin out there that achieves this, or a snippet of code that can add in an additional column? Any help would be greatly appreciated. Below is an image illustrating

Save custom delivery date from product attribute on WooCommerce order

半世苍凉 提交于 2020-07-16 05:46:08
问题 i have a custom attribute where products have different pickup times. i want to add this dates as a custom field to my wc orders, to notify my customers via cronjob that the order is ready to pickup. with the code below i get the wrong date, can anyone tell me what is wrong here? foreach ( $order->get_items() as $item_id => $item ) { $product_id = $item->get_product_id(); $order_id = $order->get_id(); $new_product = new WC_Product( $product_id ); // create an object of WC_Product class //

Add update or remove WooCommerce shipping order items

雨燕双飞 提交于 2020-07-14 09:17:57
问题 I have added shipping cost for the orders that are synced from amazon. For some reason I had to set custom shipping flat price in woo-orders created for amazon-order. It is done as follow: $OrderOBJ = wc_get_order(2343); $item = new WC_Order_Item_Shipping(); $new_ship_price = 10; $shippingItem = $OrderOBJ->get_items('shipping'); $item->set_method_title( "Amazon shipping rate" ); $item->set_method_id( "amazon_flat_rate:17" ); $item->set_total( $new_ship_price ); $OrderOBJ->update_item( $item )

Display all available shipping methods and costs on WooCommerce Order pages

风流意气都作罢 提交于 2020-07-10 10:24:19
问题 Currently in my WooCommerce based site, I am wanting to display the available shipping methods and prices on the order edit page. I am using Display ALL available shipping methods for each specific order on admin edit order pages in Woocommerce answer code to my previous question. It does not displaythe data as I want. For example, the output of my code so far results in: Method 1 Method 2 Method 3 Price 1 Price 2 Price 3 Alternatively, I would like for it to display like this: Method 1 -

Woocommerce hook before order status change

偶尔善良 提交于 2020-07-09 16:49:30
问题 I've been searching for a hook that is triggered before the order status is changed or, for that matter, before the order is updated. I'm trying to enforce a designed workflow. I've been able to change the options the users have to change the order status so they don't choose a 'wrong' status, but I want to check the updates using code too (never trust user input). There are hooks triggered after the status has changed (woocommerce_order_status[to]) that do not prevent 'illegal' status

Woocommerce hook before order status change

放肆的年华 提交于 2020-07-09 16:46:32
问题 I've been searching for a hook that is triggered before the order status is changed or, for that matter, before the order is updated. I'm trying to enforce a designed workflow. I've been able to change the options the users have to change the order status so they don't choose a 'wrong' status, but I want to check the updates using code too (never trust user input). There are hooks triggered after the status has changed (woocommerce_order_status[to]) that do not prevent 'illegal' status