WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Anyway to get individual product quantity instead of whole cart? (4 posts)

  1. bowenac
    Member
    Posted 1 year ago #

    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.

    http://wordpress.org/extend/plugins/woocommerce/

  2. Roy Ho
    Member
    Posted 1 year ago #

    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() );
  3. bowenac
    Member
    Posted 1 year ago #

    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...

  4. Roy Ho
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.