array('','char'),'selectname2'=>array('','char'),'selectname3'=>array('','char'),'selectname4'=>array('','char'), 'selectoptions1'=>array('','char'),'selectoptions2'=>array('','char'),'selectoptions3'=>array('','char'),'selectoptions4'=>array('','char') ); $this->setConfigParameterable('custom_params',$varsToPush); } // function plgVmOnOrder($product) { // $dbValues['virtuemart_product_id'] = $product->virtuemart_product_id; // $dbValues['stockable'] = $this->_virtuemart_paymentmethod_id; // $this->writeCustomData($dbValues, '#__virtuemart_product_custom_' . $this->_name); // } // get product param for this plugin on edit /** * @see components/com_virtuemart/helpers/vmCustomPlugin::plgVmOnProductEdit() * @author Matt Lewis-Garner * @author Patrick Kohl */ function plgVmOnProductEdit($field, $product_id, &$row,&$retValue) { //TODO Give warning if config not set to disableit_children if ($field->custom_element != $this->_name) return ''; $this->parseCustomParams($field); $html =''; if (!$childs = $this->getChilds($product_id) ) $html .='
'.JTEXT::_('VMCUSTOM_STOCKABLE_NO_CHILD').'
'; $db = JFactory::getDBO(); // $db->setQuery('SELECT `virtuemart_custom_id` FROM `#__virtuemart_customs` WHERE field_type="G" '); // $group_custom_id = $db->loadResult(); // $plgParam = $this->getVmCustomParams($field->virtuemart_custom_id); $html .=''.JText::_('VMCUSTOM_STOCKABLE_IS_VARIANT').''; for ($i = 1; $i<5 ;$i++) { $selectname = 'selectname'.$i ; $listname = $field->$selectname; if (!empty($listname)) { $html .=' '.JTEXT::_($listname).''; } } $html .=' '. JText::_('VMCUSTOM_STOCKABLE_PRICE') .''; // $param = json_decode($field->custom_param,true); if (isset($field->child)) $childList = $field->child; else $childList = array(); $html .= '
'; foreach ($childs as $child ) { $checked =''; $price = null; if(!empty($childList)) { if (!array_key_exists($child->id, $childList) ) $childList[$child->id]['is_variant'] = 1; if ($childList[$child->id]['is_variant'] ) $checked='checked'; if (array_key_exists('custom_price', $childList[$child->id] ) ) $price = $childList[$child->id]['custom_price'] ; } //$html .= JHTML::_('select.genericlist', $childlist, 'custom_param['.$row.'][child_id]','','virtuemart_product_id','product_name',$param['child_id'],false,true); $name='custom_param['.$row.'][child]['.$child->id.']'; $html .='
' ; $html .=' '; $html .=' '; $html .=$this->getCustomOptionsForm($field, $name, $childList[$child->id]); //$html .=''; // if (!$customfield = $this->getFieldId($product_id, $child->id) ) $price ='' ; // else $html .=''; // $html .=''; // $html .=''; $html .= ' '.$child->product_name.' ['.JText::_('COM_VIRTUEMART_PRODUCT_IN_STOCK').' : '.$child->stock.']
' ; } $html .='
'. JText::_('COM_VIRTUEMART_PRODUCT_FORM_NEW_PRODUCT_LBL').'
'. JText::_('COM_VIRTUEMART_PRODUCT_SKU').' '. JText::_('COM_VIRTUEMART_PRODUCT_NAME').' '. JText::_('VMCUSTOM_STOCKABLE_PRICE').' '. JText::_('COM_VIRTUEMART_PRODUCT_IN_STOCK').' '. JText::_('COM_VIRTUEMART_ADD').'
'; $new_fields = $this->getCustomOptionsForm($field, '{{NAME}}', array()); $script = " jQuery( function($) { $('#new_stockable_product').click(function() { var Prod = $('#new_stockable');// input[name^=\"stockable\"]').serialize(); $.getJSON('index.php?option=com_virtuemart&view=product&task=saveJS&token=".JUtility::getToken()."' , { product_sku: Prod.find('input[name*=\"product_sku\"]').val(), product_name: Prod.find('input[name*=\"product_name\"]').val(), product_price: Prod.find('input[name*=\"product_price\"]').val(), product_in_stock: Prod.find('input[name*=\"product_in_stock\"]').val(), product_parent_id: ".$product_id.", published: 1, format: \"json\" }, function(data) { //console.log (data); //$.each(data.msg, function(index, value){ // $(\"#new_stockable\").append(data.msg); //}); name='custom_param[".$row."][child]['+data.product_id+']'; new_fields = '".str_replace("\n", '', $new_fields)."'; new_fields = new_fields.replace(/\{\{NAME\}\}/g, name); $('#stockables').append( '
' + '' + '' + new_fields + '' + ' '+Prod.find('input[name*=\"product_name\"]').val()+' [".JText::_('COM_VIRTUEMART_PRODUCT_SKU')." : '+Prod.find('input[name*=\"product_sku\"]').val()+'] [".JText::_('COM_VIRTUEMART_PRODUCT_IN_STOCK')." : '+(Prod.find('input[name*=\"product_in_stock\"]').val() || 0)+']' + '
'); Prod.find('input[name*=\"product_sku\"]').val(''); Prod.find('input[name*=\"product_name\"]').val(''); Prod.find('input[name*=\"product_price\"]').val(''); Prod.find('input[name*=\"product_in_stock\"]').val(''); }); }); jQuery('input[name=field\\\\[$row\\\\]\\\\[custom_price\\\\]]').val('0.0'); }); "; //$document = JFactory::getDocument(); //$document->addScriptDeclaration($script); // $html =' '; // $html .=''; //$html .=JTEXT::_('VMCUSTOM_TEXTINPUT_NO_CHANGES_BE'); $retValue .= $html.''; return true ; } /** * Get the formatted options dropdowns and input fields (backend) * @author Matt Lewis-Garner */ function getCustomOptionsForm($field, $name, $values) { $options_html = ''; for ($i = 1; $i<5 ;$i++) { $selectoptions = 'selectoptions'.$i ; $attributes = 'attribute'.$i ; if (isset($field->$selectoptions)) $selectoption = (string)$field->$selectoptions; else $selectoption = "" ; $option = array(); $tmpOptions = str_replace( "\r", "" ,$selectoption); if ($listoptions = explode("\n",$tmpOptions ) ) { foreach ($listoptions as $key => $val) $option[] = JHTML::_('select.option',JText::_( $val ) , $val ); if (empty($values[$selectoptions])) { $values[$selectoptions] =''; } if ($listoptions[0] == '' && $field->{'selectname'.$i}) { $options_html .= '';// '.JText::_('VMCUSTOM_STOCKABLE_NO_OPTION') .''; } else if ($listoptions[0] == '') { $options_html .= ''; } else { $options_html .= JHTML::_('select.genericlist', $option, $name.'['.$selectoptions.']','style="width:100px !important;float:none;"','text','value',$values[$selectoptions],false,true)."\n"; } } } return $options_html; } /** * @ idx plugin index * @see components/com_virtuemart/helpers/vmCustomPlugin::onDisplayProductFE() * @author Matt Lewis-Garner * @author Patrick Kohl */ function plgVmOnDisplayProductVariantFE($field,&$row,&$group) { // default return if it's not this plugin if ($field->custom_element != $this->_name) return ''; $row++; $this->parseCustomParams($field); //if (!$childs = $this->getChilds($product_id) ) return ; $this->stockhandle = VmConfig::get('stockhandle','none'); $html='
'; $customfield_id = array(); $selects = array(); $js = array(); $ordered_childs = array(); // generate option with valid child results foreach($field->child as $child_id => &$attribut) { if ($attribut['is_variant']==1) { unset ($attribut['is_variant']); if ($stock = $this->getValideChild( $child_id)) { $field->child[$child_id]['in_stock'] = $stock->product_in_stock - $stock->product_ordered; // Availability Image if ($field->child[$child_id]['in_stock'] < 1) { if ($this->stockhandle == 'risetime' and VmConfig::get('rised_availability') and empty($stock->product_availability)) { $field->child[$child_id]['product_availability'] = (file_exists(JPATH_BASE . DS . VmConfig::get('assets_general_path') . 'images/availability/' . VmConfig::get('rised_availability'))) ? JHTML::image(JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' . VmConfig::get('rised_availability', '7d.gif'), VmConfig::get('rised_availability', '7d.gif'), array('class' => 'availability')) : $field->child[$child_id]['product_availability'] = VmConfig::get('rised_availability'); } else if (!empty($stock->product_availability)) { $field->child[$child_id]['product_availability'] = (file_exists(JPATH_BASE . DS . VmConfig::get('assets_general_path') . 'images/availability/' . $stock->product_availability)) ? JHTML::image(JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' . $stock->product_availability, $stock->product_availability, array('class' => 'availability')) : $field->child[$child_id]['product_availability'] = $stock->product_availability; } } //$field->child[$child_id]['product_availability'] = $stock->product_availability; if ($attribut['custom_price']) $js[]= '"'.$child_id.'" :'.$attribut['custom_price']; unset ($attribut['custom_price']); foreach ($attribut as $key => $list) { // if (!in_array($key,$selects)) { // $selects[$key] = array() ; // } // if (!in_array($list , $selects[$key]) ) { if (preg_match('/^selectoptions\d+$/', $key)) { $selects[$key][$list] = $list ; $attribut[$key] = array($list,JText::_($list)); } // } } } } else unset ($attribut); $field->child[$child_id]['child_id'] = $child_id; array_push($ordered_childs, $field->child[$child_id]); } // Javascript can be added multiple times for multiple products on a page, // so need to suffix everything for the right products $js_suffix = $field->virtuemart_customfield_id;//.'_'.uniqid(); $html .= '
'; $i = 1; foreach ($selects as $keys =>$options) { $selectname = 'selectname'.$i; $listname = $field->$selectname; if (!empty($listname)) { $optionName = 'customPlugin['.$field->virtuemart_customfield_id.']['.$this->_name.']['.$keys.']'; $option = array(); $show_select = false; foreach ($options as $key => $val) { if (!empty($val)) { if (1 == $i) { $option[] = JHTML::_('select.option', $val, JText::_( $val )); } $show_select = true; } } if ($show_select) { $html .='
'.JTEXT::_($listname).''; $html .= JHTML::_('select.genericlist', $option,$optionName ,'class="attribute_list no-vm-bind customfield_id_'.$js_suffix.'" style="width:100px !important;"','value','text',reset($options),'selectoptions'.$i,false)."
\n"; } else $html .='' ; } $i++; } $html .= '
'; static $stockablejs; $group->display = $html.' '; // preventing 2 x load javascript /*if ($stockablejs) return; $stockablejs = true ;*/ // TODO ONE PARAM IS MISSING $document = JFactory::getDocument(); $js = ' //stockhandle.'"; var stockable_ordered_'.$js_suffix.' =$.parseJSON(\'' .str_replace('\"', '\\\"', json_encode($ordered_childs)). '\') ; var selections_'.$js_suffix.' = []; var totalattribut_'.$js_suffix.' = []; // If there are selects, go thru each block, number them, record the number of selects in each, the "recalculate" if ( $("select.attribute_list.customfield_id_'.$js_suffix.'").length ) { var stockableBlockIndex = 0; $(".stockable_block_'.$js_suffix.'").each(function() { $(this).attr("id", "stockableBlockIndex_'.$js_suffix.'_" + stockableBlockIndex); totalattribut_'.$js_suffix.'[stockableBlockIndex] = $(this).find("select.attribute_list.customfield_id_'.$js_suffix.'").length+1; recalculate_'.$js_suffix.'(stockableBlockIndex, $(this).find("select.attribute_list.customfield_id_'.$js_suffix.'").eq(0)); stockableBlockIndex++; }); } // Unbind any previous change events from the selects, then rebind our change event to them $("select.attribute_list.customfield_id_'.$js_suffix.'").unbind("change"); $("select.attribute_list.customfield_id_'.$js_suffix.'").change(function(){ var stockableBlockIndex = $(this).parents(".stockable_block_'.$js_suffix.'").attr("id").split("_"); recalculate_'.$js_suffix.'(stockableBlockIndex[stockableBlockIndex.length-1], $(this)); }); // The main recalculate function (select change event handler) function recalculate_'.$js_suffix.'(stockableBlockIndex, Opt){ var found_id = 0; var currentIndex = $("#stockableBlockIndex_'.$js_suffix.'_"+stockableBlockIndex+" select.attribute_list.customfield_id_'.$js_suffix.'").index(Opt) +1; selections_'.$js_suffix.'[stockableBlockIndex] = []; var i=1; $("#stockableBlockIndex_'.$js_suffix.'_"+stockableBlockIndex+" select.attribute_list.customfield_id_'.$js_suffix.'").each(function() { selections_'.$js_suffix.'[stockableBlockIndex][i] = $(this).val(); // Clear the following selects if (i > currentIndex) { $(this).empty(); } i++; }); // Repopulate the following selects jQuery.each(stockable_ordered_'.$js_suffix.', function(index, child_attrib) { if (isChildValid_'.$js_suffix.'(stockableBlockIndex, child_attrib, currentIndex)) { populateNextSelect_'.$js_suffix.'(stockableBlockIndex, child_attrib, currentIndex+1); } }); // Identify the current child jQuery.each(stockable_ordered_'.$js_suffix.', function(index, child_attrib) { var i; for(i = 1; i < totalattribut_'.$js_suffix.'[stockableBlockIndex]; i++){ if (child_attrib["selectoptions"+i][0] != selections_'.$js_suffix.'[stockableBlockIndex][i]) { break; } } if (totalattribut_'.$js_suffix.'[stockableBlockIndex] == i) { found_id = child_attrib["child_id"]; found_child = child_attrib; return false; } }); if ("disableadd" == stockhandle && found_child.in_stock <= 0) { $(".addtocart-bar>span").remove(); $(".addtocart-bar>div").remove(); $(".addtocart-bar>a.notify").remove(); $(".addtocart-bar").append(\'' . JText::_('COM_VIRTUEMART_CART_NOTIFY') . '\'); } else { var quantity = $(".addtocart-bar .quantity-input").val(); if (isNaN(quantity)) { quantity = 1; } $(".addtocart-bar>span").remove(); $(".addtocart-bar>div").remove(); $(".addtocart-bar>a.notify").remove(); $(".addtocart-bar").append(\'
\'); Virtuemart.product($("form.product")); } $(".availability").remove(); if ("risetime" == stockhandle && found_child.product_availability) { $(".addtocart-area").after(\'
\' + found_child.product_availability + \'
\'); } // recalculate the price by found product child id; formProduct = Opt.parents("form.product"); virtuemart_product_id = formProduct.find(\'input[name="virtuemart_product_id[]"]\').val(); formProduct.find(\'input[name*="customPlugin['.$field->virtuemart_customfield_id.']['.$this->_name.'][child_id]"]\').val(found_id); Virtuemart.setproducttype(formProduct,virtuemart_product_id); } function isChildValid_'.$js_suffix.'(stockableBlockIndex, child_attrib, currentIndex) { return_value = true; for (var i = currentIndex; i > 0; i--) { if (child_attrib["selectoptions"+i][0] != selections_'.$js_suffix.'[stockableBlockIndex][i]) { return_value = false; } } return return_value; } function populateNextSelect_'.$js_suffix.'(stockableBlockIndex, child_attrib, nextIndex) { var selectList = $("#stockableBlockIndex_'.$js_suffix.'_"+stockableBlockIndex+" select.attribute_list.customfield_id_'.$js_suffix.'"); var nextSelect = selectList.eq(nextIndex-1); // if the select exists if ("undefined" !== typeof(nextSelect) && nextSelect.length > 0) { // if it doesn\'t already contain this option, add it if (nextSelect.find("option[value=\'" + child_attrib["selectoptions"+nextIndex][0] + "\']").length == 0) { nextSelect.append(""); } // if there is only one option, make it selected if (1 == nextSelect.find("option").length) { nextSelect.find("option").attr("selected","selected"); selections_'.$js_suffix.'[stockableBlockIndex][nextIndex] = child_attrib["selectoptions"+nextIndex][0]; } // if this is the selected value, populate the next select too if (nextSelect.val() == child_attrib["selectoptions"+nextIndex][0]) { populateNextSelect_'.$js_suffix.'(stockableBlockIndex, child_attrib, nextIndex+1); } } } }); //]]> '; //$document->addScriptDeclaration($js); $group->display .= ''; // 'custom_param['.$keys.']' //dump($param); //"is_variant":"1","attribute1":"Red","attribute2":"20 cm","attribute3":"10","attribute4":"10" //echo $plgParam->get('custom_info'); // Here the plugin values //$html =JTEXT::_($param['custom_name']) ; //$html.=':
'; return true; } function plgVmOnDisplayProductFE( $product, &$idx,&$group){} /** * @see components/com_virtuemart/helpers/vmCustomPlugin::plgVmOnViewCartModule() * @author Patrick Kohl */ function plgVmOnViewCartModule( $product, $row,&$html) { if (empty($product->productCustom->custom_element) or $product->productCustom->custom_element != $this->_name) return ''; if (!$plgParam = $this->GetPluginInCart($product)) return false ; foreach ($plgParam as $attributes) { foreach ($attributes as $k => $attribute) { if ($k =='child_id') continue; $html .=' '.JText::_($attribute).' '; } } return true; } /** * @see components/com_virtuemart/helpers/vmCustomPlugin::plgVmOnViewCart() * @author Patrick Kohl */ function plgVmOnViewCart($product, $row,&$html) { if (empty($product->productCustom->custom_element) or $product->productCustom->custom_element != $this->_name) return ''; if (!$plgParam = $this->GetPluginInCart($product)) return false ; $html .= '
'; foreach ($plgParam as $attributes) { foreach ($attributes as $k => $attribute) { if ($k =='child_id') continue; $html .=' '.JText::_($attribute).' '; } } // $html .=''.$param->Morecomment.''; $html.='
'; return true; //vmdebug('stockable attributs',$plgParam); } /** * * vendor order display BE */ function plgVmDisplayInOrderBE($item, $row,&$html) { if (empty($item->productCustom->custom_element) or $item->productCustom->custom_element != $this->_name) return ''; return $this->plgVmOnViewCart($item, $row,$html); } /** * * shopper order display FE */ function plgVmDisplayInOrderFE($item, $row,&$html) { if (empty($item->productCustom->custom_element) or $item->productCustom->custom_element != $this->_name) return ''; return $this->plgVmOnViewCart($item, $row,$html); } function getChilds($child_id = null) { if ($child_id) { $db = JFactory::getDBO(); $q = 'SELECT CONCAT( `product_name`, " [' .JText::_('COM_VIRTUEMART_PRODUCT_SKU').'"," : ",`product_sku`,"]") as product_name,`virtuemart_product_id` as id, `product_in_stock` as stock FROM `#__virtuemart_products_'.VMLANG.'` as l ' . ' JOIN `#__virtuemart_products` AS p using (`virtuemart_product_id`)' . ' WHERE `product_parent_id` ='.(int)$child_id . ' ORDER BY `pordering`' ; $db->setQuery($q); $result = $db->loadObjectList(); if (!($result)) { //JError::raiseWarning(500, $db->getErrorMsg()); return array(); } else return $result ; } else { return array(); } } function getFieldId($virtuemart_product_id, $child_id ) { $db = JFactory::getDBO(); $q = 'SELECT cf.* FROM `#__virtuemart_product_customfields` as cf JOIN `#__virtuemart_customs` as c ON `c`.`virtuemart_custom_id` = cf.`virtuemart_custom_id` AND c.`field_type`="G" WHERE cf.`virtuemart_product_id` ='.(int)$virtuemart_product_id.' and cf.custom_value='.(int)$child_id ; $db->setQuery($q); $result = $db->loadObject(); if (!($result)) { //JError::raiseWarning(500, $db->getErrorMsg()); return false; } else return $result ; } /** * Get the child object for the given ID if it is valid for the config * @author Matt Lewis-Garner */ function getValideChild($child_id ) { $productModel = VmModel::getModel('product'); $child = $productModel->getProduct($child_id,true,false,true,1,false); /*$db = JFactory::getDBO(); $q = 'SELECT `product_sku`,`product_name`,`product_in_stock`,`product_ordered`,`product_availability`,`product_weight` FROM `#__virtuemart_products` JOIN `#__virtuemart_products_'.VMLANG.'` as l using (`virtuemart_product_id`) WHERE `published`=1 and `virtuemart_product_id` ='.(int)$child_id ; $db->setQuery($q); $child = $db->loadObject();*/ if ($child) { if ('disableit_children' === $this->stockhandle) { $stock = $child->product_in_stock - $child->product_ordered ; if ($stock>0)return $child ; else return false ; } else return $child ; } return false ; } public function plgVmGetProductStockToUpdateByCustom(&$item, $pluginParam, $productCustom) { if ($productCustom->custom_element !== $this->_name) return false ; //vmdebug('$pluginParam',$pluginParam[$this->_name]); $item->virtuemart_product_id = (int)$pluginParam[$this->_name]['child_id']; return true ; // echo $item[0]->virtuemart_product_id;jexit(); } /** * We must reimplement this triggers for joomla 1.7 * vmplugin triggers note by Max Milbers */ public function plgVmOnStoreInstallPluginTable($psType) { // return $this->onStoreInstallPluginTable($psType); } function plgVmDeclarePluginParamsCustom($psType,$name,$id, &$data){ return $this->declarePluginParams('custom', $name, $id, $data); } function plgVmSetOnTablePluginParamsCustom($name, $id, &$table){ return $this->setOnTablePluginParams($name, $id, $table); } /** * Custom triggers note by Max Milbers */ function plgVmOnDisplayEdit($virtuemart_custom_id,&$customPlugin){ return $this->onDisplayEditBECustom($virtuemart_custom_id,$customPlugin); } public function plgVmCalculateCustomVariant($product, &$productCustomsPrice,$selected){ if ($productCustomsPrice->custom_element != $this->_name) return false; if (!$customPlugin = JRequest::getVar('customPlugin',0)) { $customPlugin = json_decode($product->customPlugin,true); } $selected = $customPlugin[$productCustomsPrice->virtuemart_customfield_id]['stockable']['child_id']; $param = json_decode($productCustomsPrice->custom_param,true); if ($child = $this->getValideChild($selected)) { if ($param['child'][$selected]['custom_price'] !=='') { $productCustomsPrice->custom_price = (float)$param['child'][$selected]['custom_price']; } else { // Get the user details $usermodel = VmModel::getModel ('user'); $currentVMuser = $usermodel->getCurrentUser (); $db = JFactory::getDbo(); if (is_array($currentVMuser->shopper_groups)) { $shgroup = $currentVMuser->shopper_groups[0]; } else { $shgroup = $currentVMuser->shopper_groups; } $query = $db->getQuery(true) ->select($db->qn('product_price')) ->from($db->qn('#__virtuemart_product_prices')) ->where($db->qn('virtuemart_product_id').' = '.(int)$selected) ->where($db->qn('virtuemart_shoppergroup_id').' = '.$shgroup); $db->setQuery($query); $price = $db->loadResult(); if (empty($price)) { // Check for price to show to all $query->clear('where') ->where($db->qn('virtuemart_product_id').' = '.(int)$selected) ->where('('.$db->qn('virtuemart_shoppergroup_id').' = 0 OR '.$db->qn('virtuemart_shoppergroup_id').' = NULL)'); $db->setQuery($query); $price = $db->loadResult(); } if (!empty($price)) $product->product_price = (float)$price; /*$db = JFactory::getDBO(); $db->setQuery('SELECT `product_price` FROM `#__virtuemart_product_prices` WHERE `virtuemart_product_id`="' . (int)$selected . '" '); if ($price = $db->loadResult()) $product->product_price = (float)$price;*/ } //TODO merge parent and child (eg product_weight) return $child; } else return false; // find the selected child } public function plgVmOnAddToCart(&$product){ $customPlugin = JRequest::getVar('customPlugin',0); if ($customPlugin) { $db = JFactory::getDBO(); $query = 'SELECT C.* , field.* FROM `#__virtuemart_customs` AS C LEFT JOIN `#__virtuemart_product_customfields` AS field ON C.`virtuemart_custom_id` = field.`virtuemart_custom_id` WHERE `virtuemart_product_id` =' . $product->virtuemart_product_id.' and `custom_element`="'.$this->_name.'"'; $query .=' and is_cart_attribute = 1'; $db->setQuery($query); $productCustomsPrice = $db->loadObject(); if (!$productCustomsPrice) return null; // if ( !in_array($this->_name,$customPlugin[$productCustomsPrice->virtuemart_custom_id]) ) return false; $selected = $customPlugin[$productCustomsPrice->virtuemart_customfield_id]['stockable']['child_id']; if (!$child = $this->plgVmCalculateCustomVariant($product, $productCustomsPrice,$selected) ) return false; /*if ($child->product_sku) $product->product_sku = $child->product_sku; if ($child->product_name) $product->product_name = $child->product_name; $product->product_in_stock = $child->product_in_stock;*/ foreach ($product as $key => $value) { if ('virtuemart_product_id' != $key) { if ($child->$key) { $product->$key = $child->$key; } } } $product->product_in_stock = $child->product_in_stock; $this->stockhandle = VmConfig::get('stockhandle','none'); if ('disableit' == $this->stockhandle || 'disableit_children' == $this->stockhandle || 'disableadd' == $this->stockhandle) { if (!class_exists ('VirtueMartCart')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'); } $cart = VirtueMartCart::getCart (); $orderedQuantity = $product->quantity; foreach ($cart->products as $cartProduct) { $cartProductParam = json_decode($cartProduct->customPlugin); if ($cartProductParam->{$productCustomsPrice->virtuemart_customfield_id}->stockable->child_id == $selected) { $orderedQuantity += $cartProduct->quantity; if ($orderedQuantity > $product->product_in_stock) { return false; } } } } } } public function plgVmDisplayInOrderCustom(&$html,$item, $param,$productCustom, $row ,$view='FE'){ $this->plgVmDisplayInOrderCustom($html,$item, $param,$productCustom, $row ,$view); } public function plgVmCreateOrderLinesCustom(&$html,$item,$productCustom, $row ){ // $this->createOrderLinesCustom($html,$item,$productCustom, $row ); } } // No closing tag