Skip to content

Instantly share code, notes, and snippets.

@hedqvist
Created September 15, 2020 06:43
Show Gist options
  • Select an option

  • Save hedqvist/2502f95783eafb746df7caf254269ddd to your computer and use it in GitHub Desktop.

Select an option

Save hedqvist/2502f95783eafb746df7caf254269ddd to your computer and use it in GitHub Desktop.
Unifaun - Force Weight
<?php
/**
* @snippet WooCommerce - Adds Default weight to parcel
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.5.1
*/
function redlight_unifaun_force_minimum_weight( $shipment, $order) {
foreach( $shipment['parcels'] as $i => $parcel ) {
$shipment['parcels'][$i]['weight'] = 0;
}
return $shipment;
}
add_filter('ac_wc_unifaun_shipment_data', 'redlight_unifaun_force_minimum_weight', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment