Doesn't seem to work for me.
It is like it don't know the difference between 0 and a value higher then zero.
Would still appreciate it a lot if someone has a solution for me!
The problem is that the field names are dynamic so this is why I advised to setup the names with 'product_', so in a hook you can find any values with this prefix, explode them and then dictate their return - someone may be able to advise you on the correct php for this as I assume mine didnt work wink
Try this - it may not work but if it fails check the error log for guidance or keep tweaking it to get it work smiley I think each time it loops through the value may be replaced though so I think you need to use str replace... hopefully someone can guide you on that.
<?php $allValues = $hook->getValues(); $product = array(); foreach($allValues as $key => $value) { if (strpos($key, 'products_') !== false) { $modx->log(xPDO::LOG_LEVEL_ERROR, 'There were values found with the prefix product_'); list($prefix, $productTitle) = explode('_', $key); $modx->log(xPDO::LOG_LEVEL_ERROR,'The products found were:' . $productTitle); $productList .= 'Title:' . $product[$key] . 'Quantity' . $product[$value]; $hook->setValue('products', $productList); return true; } else{ $modx->log(xPDO::LOG_LEVEL_ERROR, 'There were no values matching product_'); return false; } }