Created
May 14, 2015 21:52
-
-
Save maxrice/fdb99fa6a3eef1bc9745 to your computer and use it in GitHub Desktop.
WooCommerce Shipwire - set a custom shipping method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wc_shipwire_set_custom_shipping_method( $fields, $order_id ) { | |
$fields['shipping_code'] = 'GD'; | |
$order = wc_get_order( $order_id ); | |
foreach ( $order->get_shipping_methods() as $method ) { | |
if ( '2-Day Shipping' == $method['name'] ) { | |
$fields['shipping_code'] = '2D'; | |
break; | |
} | |
} | |
return $fields; | |
} | |
add_filter( 'wc_shipwire_order_defaults', 'wc_shipwire_set_custom_shipping_method', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment