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 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; | |
} |
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 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 Add or Update Post 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_post_number', 10, 2); | |
function modify_post_number($args, $order_id) { | |
if( $order_id == 12345 ){ | |
$args['shipping_address']['dhl_postnum'] = 54321; | |
} | |
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 gist:d1c32e93dad8008dddd9151b69e0994c
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', 'remove_phone_number', 10, 2); | |
function remove_phone_number($args, $order_id) { | |
if(isset($args['shipping_address']['phone'])){ | |
unset($args['shipping_address']['phone']); | |
} | |
return $args; | |
} |
View gist:a7bc62eb3dc50145fcd331023c022cf5
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', 'remove_email_number', 10, 2); | |
function remove_email_number($args, $order_id) { | |
if(isset($args['shipping_address']['email'])){ | |
unset($args['shipping_address']['email']); | |
} | |
return $args; | |
} |
View Change SKU argument to Product ID
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) { | |
if( isset( $item_value['sku'] ) ) { | |
$product_id = wc_get_product_id_by_sku( $item_value['sku'] ); | |
if( $product_id ) { | |
$args['items'][ $item_key ]['sku'] = $product_id; | |
} | |
} |
View Ensure Item Price 2 Decimal Float
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_price', 10, 2); | |
function modify_item_price($args, $order_id) { | |
if( isset( $args['items'] ) ) { | |
foreach ($args['items'] as $item_key => $item_value) { | |
if( isset( $item_value['item_value'] ) ) { | |
$args['items'][ $item_key ]['item_value'] = round( floatval( $item_value['item_value'] ), 2); | |
} | |
} | |
} | |
return $args; |
NewerOlder