Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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;
}
@Nex4rius

This comment has been minimized.

Copy link

@Nex4rius Nex4rius commented Aug 1, 2021

This solution works for all instead of just 1 order.

add_filter('pr_shipping_dhl_label_args', 'modify_post_number', 10, 2);
function modify_post_number($args, $order_id) {
    $postnumber = get_post_meta($order_id, "_shipping_dhl_postnumber", true);
    if($postnumber){
        $args['shipping_address']['dhl_postnum'] = $postnumber;
    }
    return $args;
}

At least if the postnumber is correctly entered here:

@shadimanna

This comment has been minimized.

Copy link
Owner Author

@shadimanna shadimanna commented Aug 2, 2021

I am not sure I understand the issue @Nex4rius, can you try to explain?

@Nex4rius

This comment has been minimized.

Copy link

@Nex4rius Nex4rius commented Aug 3, 2021

Your solution has the hardcoded order_id and postnumber which obviously only works on this one order. I made it generalized for all orders. It's just strange that the DHL plugin adds the postnumber field but somehow still complains that the postnumber is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment