View Modify order id to order number
This file contains 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
add_filter('pr_shipping_dhl_label_args', 'modify_order_id_to_number', 10, 2); | |
function modify_order_id_to_number($args, $order_id) { | |
$order = wc_get_order( $order_id ); | |
$args['dhl_settings']['dhl_label_ref'] = $order->get_order_number(); | |
return $args; | |
} |
View Weight in DE
This file contains 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
add_filter('pr_shipping_dhl_order_weight', 'custom_add_weight', 10, 2); | |
function custom_add_weight($total_weight, $order_id) { | |
$order = wc_get_order( $order_id ); | |
if ($order) { | |
$shipping_address = $order->get_address( 'shipping' ); | |
if( $shipping_address['country'] == 'DE' ) { | |
return 30; | |
} | |
} |
View Remove state if does not have at least 2 chars
This file contains 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
add_filter('pr_shipping_dhl_label_args', 'maybe_remove_state', 10, 2); | |
function maybe_remove_state($args, $order_id) { | |
if( isset( $args['shipping_address']['state'] ) && ( strlen( $args['shipping_address']['state'] ) < 2 || strlen( $args['shipping_address']['state'] ) > 20 ) ) { | |
unset($args['shipping_address']['state']); | |
} | |
return $args; | |
} |
View Add Company Name to DPI API Call
This file contains 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
add_filter('pr_shipping_dhl_label_args', 'maybe_add_company', 10, 2); | |
function maybe_add_company($args, $order_id) { | |
if( ! empty( $args['shipping_address']['company'] ) ) { | |
if( ! empty( $args['shipping_address']['address_2'] ) ) { | |
$args['shipping_address']['address_2'] = $args['shipping_address']['address_1'] . ', ' . $args['shipping_address']['address_2']; | |
} else { | |
$args['shipping_address']['address_2'] = $args['shipping_address']['address_1']; | |
} | |
$args['shipping_address']['address_1'] = $args['shipping_address']['company']; | |
} |
View Change customs item description
This file contains 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
add_filter('pr_shipping_dhl_label_args', 'modify_item_sku', 10, 2); | |
function modify_item_sku($args, $order_id) { | |
if( isset( $args['items'] ) ) { | |
foreach ($args['items'] as $item_key => $item_value) { | |
$item_value['item_description'] = "ENTER THE DESCRIPTION YOU WANT"; | |
} | |
} | |
return $args; | |
} |
OlderNewer