Skip to content

Instantly share code, notes, and snippets.

@varun-pluginhive
Created December 3, 2018 11:36
Show Gist options
  • Save varun-pluginhive/a59ff76a71e33dd97303f931375d2ad5 to your computer and use it in GitHub Desktop.
Save varun-pluginhive/a59ff76a71e33dd97303f931375d2ad5 to your computer and use it in GitHub Desktop.
Snippet to set minimum weight of UPS Package. WooCommerce UPS Shipping Plugin with Print Label - https://www.pluginhive.com/product/woocommerce-ups-shipping-plugin-with-print-label/
/**
* Snippet to set minimum weight of UPS Package.
* Created at : 03 Dec 2018
* Updated at : 03 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/a59ff76a71e33dd97303f931375d2ad5
*/
add_filter( 'ph_ups_generated_packages', function( $packages ){
$min_weight = 0.5; // Minimum Weight of Package
foreach( $packages as &$package ) {
if( $min_weight > (double) $package['Package']['PackageWeight']['Weight'] ) {
$package['Package']['PackageWeight']['Weight'] = $min_weight;
}
}
return $packages;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment