• Resolved koolmind

    (@koolmind)


    Good evening.
    Due to my client needs, I had to write some code to change the weight of my cart, to be able to apply some charge on shipping fees in case my cart contains specific items.

    I wrote a function that makes all the calculations, and returns the new weight of the cart.

    function set_my_weight($weight) {
      global $woocommerce;
      $cart_items = $woocommerce->cart->get_cart();
    
      // all the magic here (a lot of code... not interesting now)
    
      return $weight;
    }
    add_filter('woocommerce_cart_contents_weight', 'set_my_weight',10,1);

    Your plugin seems not to look a the cart weight. It seems to calculate the total weight article by article, instead. That’s a real problem to me.

    Is there a way to force your plugin to get the correct value by a WooCommerce function?

    Thanks

Viewing 1 replies (of 1 total)
  • Plugin Author Dan

    (@dangoodman)

    Hello,

    Right, the plugin sums the weight of each item.

    Due to the way it’s organized internally the easiest option is to adjust items weights according to the total cart weight and/or add fake items.

Viewing 1 replies (of 1 total)
  • The topic ‘Plugin ignore my weight modifications’ is closed to new replies.