Last active
January 30, 2025 09:53
-
-
Save hedqvist/ef4c7a8c556d424e8cc6764c47e5325a to your computer and use it in GitHub Desktop.
PostNord - Papersize depending on Shipping method
This file contains hidden or 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
<?php | |
/** | |
* @snippet WooCommerce - Sets size of shippinglabel to LETTER for certain orders and LABEL for certain | |
* @author Redlight Media AB / Christopher Hedqvist | |
* @compatible WooCommerce 7.2.0 | |
*/ | |
function redlight_postnord_papersize( $papersize, $order ) { | |
$shipping_method = $order->get_shipping_method(); | |
if( in_array( $shipping_method, array( 'Ombud', 'Hemleverans' ) ) ){ | |
$papersize = 'LABEL'; | |
} | |
if( in_array( $shipping_method, array( 'Varubrev' ) ) ){ | |
$papersize = 'LETTER'; | |
} | |
return $papersize; | |
} | |
add_filter('redlight_wcpns_get_label_papersize', 'redlight_postnord_papersize', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment