Support » Plugin: WooCommerce » Variable product stock / add to cart warning since WC 3.0.x

  • This might be an issue or a misinterpretation on my part, but…

    I have a variable product (event tickets with adult and child pricing variations) with stock managed at the product level, NOT at the variation level. (So there are a fixed number of tickets, which can be sold in any combination of child and adult variations adding up to the total number of tickets.)

    Let’s say that there are 2 tickets left in stock. If I add 2 adult tickets to my cart and then try to add another ticket (whether child or adult), the following notice pops:

    Notice: Undefined offset: 3867 in /home/devtryst/public_html/wp-content/plugins/woocommerce/includes/class-wc-cart.php on line 943

    I also see the expected in-page warning, but with an erroneous product count:

    You cannot add that amount to the basket — we have 2 in stock and you already have 0 in your basket.

    The undefined offset mentioned above is the product ID of the *variation* (not the main parent product); the sprintf on line 943 appears to be trying to get the number of items in the basket from the variation you’re trying to buy, not from the parent product ID of that variation. (The cart seems to store the parent; the method get_cart_item_quantities() reports a cart containing 2 of the parent product with ID 3865 in this case).

    Is this a bug in the error reporting, or is something else awry with the cart or the inventory setup for this variable product?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Variable product stock / add to cart warning since WC 3.0.x’ is closed to new replies.