Filter not applied on : ‘woocommerce_cart_contents_weight’

  hook, php, woocommerce, wordpress

I’m trying to take account of the package weight in the total weight of the cart so I can bill the right shipping cost.

I tried adding a filter on ‘woocommerce_cart_contents_weight’ like explained there

So I added the following code snippet

function add_package_weight_to_cart_contents_weight( $weight ) {        
    $weight = $weight * 1.3; // add 30%     
    return $weight;     

add_filter('woocommerce_cart_contents_weight', 'add_package_weight_to_cart_contents_weight');

I’ve also added a snippet to print cart weight on cart page, and I can see that the weight filter isn’t applied : The total weight of the cart doesn’t change wether the snippet is active or not.

I also tried putting exactly 900g articles in the cart so that, with the box weight, it goes over 1kg and change price, but the shipping price is still the one for under 1kg.

Any idea on why it isn’t applied and how I could fix it ?

Source: Ask PHP