Skip to content

Instantly share code, notes, and snippets.

@webdados
Created February 27, 2026 13:57
Show Gist options
  • Select an option

  • Save webdados/be8a363fc4154c6cdb913385c98f28af to your computer and use it in GitHub Desktop.

Select an option

Save webdados/be8a363fc4154c6cdb913385c98f28af to your computer and use it in GitHub Desktop.
Use order customer note as observations on the DPD Portugal for WooCommerce labels
<?php
// Works on DPD Portugal for WooCommerce 14.0 and above
add_filter( 'woo_dpd_portugal_shipment_data', function( $shipment_data, $order_id ) {
if ( empty( trim( $shipment_data['comments'] ) ) ) {
$order = wc_get_order( $order_id );
if ( $order ) {
$shipment_data['comments'] = trim( $order->get_customer_note() );
}
}
return $shipment_data;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment