Support » Plugin: WooCommerce » Anyway to get individual product quantity instead of whole cart?

  • bowenac


    I am trying to modify the class-wc-tax.php to support some states where tax is only on items costing more than $175 per item.

    I have this working but only on single items. If someone adds two items that are $100 each so $200-175=25 it then taxes the extra $25 and thinks it is a single item.

    My plan is to get the individual product quantity and divide that by the total price of quantity.

    Example: Added two $100 items to cart, I want to get the quantity of this which is 2, take the total which is 200/2 = 100.

    The only quantity I can get is the total cart quantity. Anyone know if it is possible to get the cart product/item quantity.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Roy Ho


    Well one way is you can always look into the woocommerce global and get the contents of the cart which has methods to do so and it will have quantity per item information there.

    So something like this.

    global $woocommerce;
    var_dump( $woocommerce->cart->get_cart() );


    Ok thanks so doing that dumps everything and I find this [“quantity”]=> string(1) “2” how would I use that. I am still pretty new to this…

    Roy Ho


    You were asking if there is a way to get the quantity of the item in the cart on a item level right? Is the solution I provided not useable? It tells you exactly what item is in the cart along with ID and quantity so with that information, you should be able to use it for your tax calculating purposes.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Anyway to get individual product quantity instead of whole cart?’ is closed to new replies.