Get orders shipping items details in WooCommerce 3

If you want to get the Order Items Shipping data, you need first to get them in a foreach loop (for ‘shipping’ item type) and to use WC_Order_Item_Shipping methods to access data $order_id = 528; // For example // An instance of $order = wc_get_order($order_id); // Iterating through order shipping items foreach( $order->get_items( ‘shipping’ ) … Read more

WooCommerce – Hide other shipping methods when FREE SHIPPING is available

There is this recent code snippet for WooCommerce 2.6+. that you can Use: add_filter( ‘woocommerce_package_rates’, ‘hide_other_shipping_when_free_is_available’, 100, 2 ); function hide_other_shipping_when_free_is_available( $rates, $package ) { $free = array(); foreach ( $rates as $rate_id => $rate ) { if ( ‘free_shipping’ === $rate->method_id ) { $free[ $rate_id ] = $rate; break; } } return ! empty( … Read more