Created
May 22, 2015 00:33
-
-
Save tamarazuk/b34fba0cb341db5b0a81 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