Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save maxrice/fdb99fa6a3eef1bc9745 to your computer and use it in GitHub Desktop.
Save maxrice/fdb99fa6a3eef1bc9745 to your computer and use it in GitHub Desktop.
WooCommerce Shipwire - set a custom shipping method
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