Say you have a product, and have added the "No Quantity" feature to it. During checkout you'll get an error like this:
warning: Invalid argument supplied for foreach() in sites/default/modules/ecommerce/ec_checkout/ec_checkout.checkout.inc on line 154.
This error happens in ec_checkout_checkout_update() where it tries to run a foreach loop:
<?php
foreach ($form_state['values']['items'] as $nid => $item) {
?>
This loop updates the quantity of each item by updating the qty element of each item within $form_state['txn']
It gets the new quantity values from $form_state['values']['items'] - which doesn't exist if the product has the "No quantity" feature.
All we need to do is to check if $form_state['values']['items'] exists before the foreach loop.
Comments
Comment #1
burningdog commentedPatch attached.
Comment #3
burningdog commentedDoh - needed to create the patch from the top folder.
Comment #4
gordon commentedComment #5
gordon commentedThis has nothing to do with the No Quantity attribute, but will create an error when there is no products in your transaction.
Comment #7
burningdog commentedOk, help me debug this, then. I *do* have products in my transaction, and I get the above foreach error. I have 1 product in my cart, and although it shows up in
$form_state['txn']it doesn't show up in$form_state['values']['items']At /checkout the screen looks like this: https://skitch.com/rogersaner/rhx6f/checkout-quantity
Note the blank value of the "Qty" field.
When the checkout process gets to the point where ec_checkout_checkout_update() is called, while
$form_state['values']['items']is blank,$form_state['txn']has the following value:To test this, I added the "No quantity" feature to the Generic Product, and then attempted to buy a Generic Product node.