Virtuemart 2.0.6
When I insert the code below in cart.php just after the line with:
$virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array');
The error message isn't generated when the parent item is added. Is this the right place to insert this code?
-----------------------------------------------------
if (sizeof($virtuemart_product_ids)>0) {
$jobDb = JFactory::getDbo();
$sqlStmt = 'SELECT c.custom_title FROM #__virtuemart_products p, #__virtuemart_product_customfields f, #__virtuemart_customs c
WHERE p.product_parent_id=0 and p.virtuemart_product_id='.$virtuemart_product_ids[0].' and
p.virtuemart_product_id=f.virtuemart_product_id and c.field_type=\'A\' and c.virtuemart_custom_id=f.virtuemart_custom_id';
$jobDb->setQuery($sqlStmt);
$jobResult = $jobDb->loadResult();
if ($jobResult != null) {
$errorMsg = "You must choose " . $jobResult;
$this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$this->json->msg .= '<div>'.$errorMsg.'</div>';
$this->json->stat = '2';
echo json_encode($this->json);
jExit();
}
}
-----------------------------------------------------
Update:
The error message pop ups only if the option 'Display modal popup upon 'Add to cart'' in [Components, Virtuemart, Configuration, Checkout] is checked. If this option is not checked, the error message will not appear and the parent can be added to the shopping cart.