Skip to content

Instantly share code, notes, and snippets.

@alexphelps
Last active May 27, 2016 01:52
Show Gist options
  • Save alexphelps/c388dc191f7f44fdaf538575ac1d8591 to your computer and use it in GitHub Desktop.
Save alexphelps/c388dc191f7f44fdaf538575ac1d8591 to your computer and use it in GitHub Desktop.
WooCommerce UPS Shipping Default Product Weight
add_filter( 'woocommerce_shipping_init', 'set_default_product_weight', 1 );
function set_default_product_weight( ) {
if ( ! is_admin() ) {
foreach ( WC()->cart->get_cart() as $item_id => $values ) {
$_product = $values['data'];
if ( empty( $_product->weight ) ) {
$_product->weight = 1.00;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment