Packaging weight per Shipping class
-
Hi there,
is there any way to add a packaging weight to the total weight?
I’ve tried it with this:
`add_filter( ‘woocommerce_cart_contents_weight’, ‘add_packaging_weight’, 10, 1 );
function add_packaging_weight( $weight )
{
$weight = 0;
foreach ( WC()->cart->get_cart() as $cart_item )
{
$product = $cart_item[‘data’];
if ( $product->get_shipping_class() == ‘kalender’ && $product->has_weight() )
$weight += (float) 0.2;
elseif ( $product->get_shipping_class() == ‘klein’ && $product->has_weight() )
$weight += (float) 0.15;
elseif ( $product->get_shipping_class() == ‘mittel’ && $product->has_weight() )
$weight += (float) 0.3;
elseif ( $product->get_shipping_class() == ‘poster-gross’ && $product->has_weight() )
$weight += (float) 0.3;
}
return $weight;
}‘
But it seems that the plugin doesn’t use the cart weight, it calculate it by itself.
Is there maybe a filter hook that I can use to manipulate the shipping weight?
I do have several different products and the parcels have different weights. But I have to add theme before I buy the shipping labels….Bets Regards Andreas
- The topic ‘Packaging weight per Shipping class’ is closed to new replies.