Created
March 13, 2020 08:53
-
-
Save hedqvist/c3370b65aa6505bc0f5c72d9862cc0cb to your computer and use it in GitHub Desktop.
Unifaun - Weight depending on service
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 - Adds Default weight to parcel depending on service | |
| * @author Redlight Media AB / Christopher Hedqvist | |
| * @compatible WooCommerce 3.5.3 | |
| */ | |
| function redlight_unifaun_minimum_weight_per_service( $shipment, $order) { | |
| foreach( $shipment['parcels'] as $i => $parcel ) { | |
| if( $shipment['parcels'][$i]['weight'] < 0.150 && 'PUA' === $shipment['service']['id'] ){ | |
| $shipment['parcels'][$i]['weight'] = 0.150; | |
| } | |
| if( $shipment['parcels'][$i]['weight'] < 1.0 && 'ASPO' === $shipment['service']['id'] ){ | |
| $shipment['parcels'][$i]['weight'] = 1.0; | |
| } | |
| } | |
| return $shipment; | |
| } | |
| add_filter('ac_wc_unifaun_shipment_data', 'redlight_unifaun_minimum_weight_per_service', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment