Skip to content

Instantly share code, notes, and snippets.

@shadimanna
Created November 20, 2019 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shadimanna/6478005ed4e470b5cc8457d8a4d1022e to your computer and use it in GitHub Desktop.
Save shadimanna/6478005ed4e470b5cc8457d8a4d1022e to your computer and use it in GitHub Desktop.
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;
}
}
}
}
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment