Pick List includes a hook in the Pick Order view that allows developers to add custom shipping actions, such as generating labels with third-party shipping plugins.
NOTE: Hook added in vs 2.6.5
This is useful when a store uses an external shipping provider integration, for example:
- GLS
- Bring
- PostNord
- DHL
- custom shipping workflows
Hook
do_action( 'cas_pick_order_shipping_actions', $order );
Parameters
$order
A WooCommerce order object (WC_Order).
Example: Add a custom shipping button
The example below adds a custom button in the Pick Order view.
add_action( 'cas_pick_order_shipping_actions', function( $order ) { if ( ! $order instanceof WC_Order ) {
return;
} $order_id = $order->get_id(); echo '<a href="#" class="button button-secondary">';
echo esc_html__( 'Generate Shipping Label', 'your-textdomain' );
echo '</a>';} );
Example: Add a button with order ID in the URL
This example builds a custom admin URL and passes the order ID.
add_action( 'cas_pick_order_shipping_actions', function( $order ) { if ( ! $order instanceof WC_Order ) {
return;
} $order_id = $order->get_id(); $url = add_query_arg(
array(
'action' => 'generate_shipping_label',
'order_id' => $order_id,
),
admin_url( 'admin-post.php' )
); echo '<a href="' . esc_url( $url ) . '" class="button button-secondary">';
echo esc_html__( 'Generate Shipping Label', 'your-textdomain' );
echo '</a>';} );
Example: Add a GLS button
If you already have a custom GLS integration, you can use the hook like this:
add_action( 'cas_pick_order_shipping_actions', function( $order ) { if ( ! $order instanceof WC_Order ) {
return;
} $order_id = $order->get_id(); $url = add_query_arg(
array(
'action' => 'generate_gls_label',
'order_id' => $order_id,
),
admin_url( 'admin-post.php' )
); echo '<a href="' . esc_url( $url ) . '" class="button button-secondary">';
echo esc_html__( 'Generate GLS Label', 'your-textdomain' );
echo '</a>';} );
Example: Handle the custom action
If you use admin-post.php, you can handle the request like this:
add_action( 'admin_post_generate_gls_label', function() { if ( ! current_user_can( 'manage_woocommerce' ) ) {
wp_die( esc_html__( 'You do not have permission to perform this action.', 'your-textdomain' ) );
} $order_id = isset( $_GET['order_id'] ) ? absint( wp_unslash( $_GET['order_id'] ) ) : 0; if ( $order_id <= 0 ) {
wp_die( esc_html__( 'Invalid order ID.', 'your-textdomain' ) );
} // Add your GLS label generation logic here. wp_safe_redirect( wp_get_referer() ? wp_get_referer() : admin_url() );
exit;} );
Recommended use
This hook is intended for:
- custom shipping label integrations
- third-party shipping plugins
- provider-specific shipping workflows
- warehouse-specific actions in the Pick Order view
Notes
- Pick List does not generate provider-specific labels through this hook.
- The hook is meant as an integration point for developers.
- Always validate permissions and sanitize request data in custom code.
Suggested snippet location
You can add custom snippets in:
- your theme’s
functions.php - a custom plugin
- a snippets plugin such as Code Snippets