WooCommerce Product Bundles - Cart Quantity

后端 未结 3 697
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-24 23:28

Configuration:

WordPress 4.1 The Events Calendar PRO 3.9 The Events Calendar: WooCommerce Tickets 3.9 WooCommerce 2.2.11 WooCommerce Product Bundles 4.6.2 For an Events

3条回答
  •  独厮守ぢ
    2021-01-25 00:12

    With heaps of help from @helgatheviking I have been able to come up with the following solution in my functions.php:

    function cit_update_cart_count() {
        global $woocommerce;
        $count = 0;
        $cart = $woocommerce->cart->get_cart();
        foreach ($cart as $key => $value) {
            if (!isset($value['bundled_items'])) {
                $count += $value['quantity'];
            }
        }
        $woocommerce->cart->cart_contents_count = $count;
    }
    add_action('init','cit_update_cart_count',10);
    

提交回复
热议问题