';
//We dont want to update always the stock, this would lead to wrong stocks, if the store has activity, while the vendor is editing the product
//$html .= '
';
return $html;
}
/**
* @author Max Milbers
* @param $field
* @param $product_id
* @param $row
*/
public function displayProductCustomfieldBE ($field, $product, $row) {
//This is a kind of fallback, setting default of custom if there is no value of the productcustom
$field->customfield_value = (!isset($field->customfield_value) or $field->customfield_value==='') ? $field->custom_value : $field->customfield_value;
$field->customfield_price = empty($field->customfield_price) ? 0 : $field->customfield_price;
if(is_object($product)){
$product_id = $product->virtuemart_product_id;
$virtuemart_vendor_id = $product->virtuemart_vendor_id;
} else {
$product_id = $product;
$virtuemart_vendor_id = vmAccess::isSuperVendor();
vmdebug('displayProductCustomfieldBE product was not object, use for productId '.$product_id.' and $virtuemart_vendor_id = '.$virtuemart_vendor_id);
}
//vmdebug('displayProductCustomfieldBE',$product_id,$field,$virtuemart_vendor_id,$product);
//the option "is_cart_attribute" gives the possibility to set a price, there is no sense to set a price,
//if the custom is not stored in the order.
if ($field->is_input or $field->field_type == 'PB' ) {
$vendor_model = VmModel::getModel('vendor');
$vendor = $vendor_model->getVendor($virtuemart_vendor_id);
$currency_model = VmModel::getModel('currency');
$vendor_currency = $currency_model->getCurrency($vendor->vendor_currency);
$priceInput = ' '.$vendor_currency->currency_symbol."";
}
else {
$priceInput = ' ';
}
$serials = '';
if(!empty($field->is_input)){
if(isset($field->product_sku)){
$serials = '
'.JHtml::_ ('select.genericlist', $options, 'field[' . $row . '][customfield_value]', '', 'value', 'text', $field->customfield_value) ;
if($field->round){
$html .= '';
}
return $html.$serials;
/* parent hint, this is a GROUP and should be G not P*/
case 'G':
return $field->customfield_value . '
';
break;
/* image */
case 'M':
if($field->is_list and $field->is_input){
$html = $priceInput . '
is list ';
$values = explode (';', $field->custom_value);
foreach($values as $val){
$html .= $this->displayCustomMedia ($val,'product');
}
return $html.$serials;
} else {
if(empty($field->custom_value)){
$q = 'SELECT `virtuemart_media_id` as value,`file_title` as text FROM `#__virtuemart_medias` WHERE `published`=1
AND (`virtuemart_vendor_id`= "' . $virtuemart_vendor_id . '" OR `shared` = "1" ) ORDER BY `file_title` ';
$db = JFactory::getDBO();
$db->setQuery ($q);
$options = $db->loadObjectList ();
} else {
$values = explode (';', $field->custom_value);
$mM = VmModel::getModel('media');
foreach ($values as $key => $val) {
if(empty($val)) continue;
$file = $mM->getFile($val);
if(empty($file->file_type)){
vmAdminInfo('The media customfield "'.$field->custom_title.'" with custom_id = '.$field->virtuemart_custom_id.' tries to load a non existing media with id = '.$val);
continue;
}
$tmp = array('value' => $val, 'text' => $file->file_name);
$options[] = (object)$tmp;
}
}
return $priceInput . '
';
//}
}
/*
JLoader::register('VirtuemartViewProduct', VMPATH_ADMIN.'/views/product/view.html.php');
$view = new VirtuemartViewProduct();
$view->addTemplatePath(VMPATH_ROOT .'/administrator/templates/vmadmin/html/com_virtuemart/product');
$pModel->addImages($relateds,1);
$view->relatedType = "products";
$view->relatedDatas = $relateds;
$view->relatedIcon = 'product';
//vmEcho::$echoDebug=true;
//vmdebug('my field',$field);
$view->virtuemart_custom_id = $field->virtuemart_custom_id;
$view->setLayout('product_edit');
$display = $view->loadTemplate('custom_relatedcf');
// the template is the same for categories and products
$js = "
var template = jQuery('#vmuikit-js-relatedcf-template').html()
var rendered = Mustache.render(template,
{
'relatedDatas': " . json_encode($relateds) . " ,
}
)
jQuery('#vmuikit-js-related".$view->relatedType."-container-".$field->virtuemart_custom_id."').html(rendered)
";
vmJsApi::addJScript('related'.$view->relatedType.'.'.".$field->virtuemart_custom_id.".'.mustache', $js);
$view->relatedType = "";
$view->relatedDatas = array();
} else {//*/
$display = '
'. vmText::_('COM_VIRTUEMART_PRODUCT_RELATED_SEARCH') .'
'. $prodStr .'
';
//}
return $display;
}
}
static $customfieldRenderer = true;
/**
* @author Max Milbers
* @param $product
* @param $customfield
*/
public static function displayProductCustomfieldFE (&$product, &$customfields) {
$session = JFactory::getSession ();
$virtuemart_category_id = $session->get ('vmlastvisitedcategoryid', 0, 'vm');
if(self::$customfieldRenderer){
$lPath = VmView::getVmSubLayoutPath ('customfield');
if($lPath){
require ($lPath);
} else {
vmdebug('displayProductCustomfieldFE layout not found customfield');
}
if(class_exists('VirtueMartCustomFieldRenderer')) {
self::$customfieldRenderer = false;
} else {
vmError('VirtueMartCustomFieldRenderer not found');
}
}
VirtueMartCustomFieldRenderer::renderCustomfieldsFE($product, $customfields, $virtuemart_category_id);
}
/**
* There are too many functions doing almost the same for my taste
* the results are sometimes slighty different and makes it hard to work with it, therefore here the function for future proxy use
*
*/
static public function displayProductCustomfieldSelected ($product, $html, $trigger) {
if(self::$customfieldRenderer){
self::$customfieldRenderer = false;
$lPath = VmView::getVmSubLayoutPath ('customfield');
if($lPath){
require ($lPath);
} else {
vmdebug('displayProductCustomfieldFE layout not found customfield');
}
}
return VirtueMartCustomFieldRenderer::renderCustomfieldsCart($product, $html, $trigger);
}
/**
* TODO This is html and view stuff and MUST NOT be in the model, notice by Max
* render custom fields display cart module FE
*/
static public function CustomsFieldCartModDisplay ($product) {
return self::displayProductCustomfieldSelected ($product, '
', 'plgVmOnViewCartModule');
}
/**
* render custom fields display cart FE
*/
static public function CustomsFieldCartDisplay ($product) {
return self::displayProductCustomfieldSelected ($product, '
', 'plgVmOnViewCart');
}
/**
* render custom fields display order BE/FE
*/
static public function CustomsFieldOrderDisplay ($item, $view = 'FE', $absUrl = FALSE) {
if(empty($item->virtuemart_product_id)) return false;
if (!empty($item->product_attribute)) {
$item->customProductData = vmJsApi::safe_json_decode ($item->product_attribute, TRUE);
}
return self::displayProductCustomfieldSelected ($item, '
', 'plgVmDisplayInOrder' . $view);
}
static function displayCustomMedia ($media_id, $table = 'product', $width = false, $height = false, $absUrl = false, $attribs = '') {
$data = VmTable::getInstance('Medias', 'Table', array('dbo'=>JFactory::getDbo()));
if(!empty($media_id)) {
$data->load ((int)$media_id);
}
if(!empty($data->file_type)){
$table = $data->file_type;
}
//in case there is no media, set the extension to an image, to show "no media set"
if(empty($data->file_url)){
$data->file_url = '.jpg';
}
$media = VmMediaHandler::createMedia ($data, $table);
return $media->displayMediaThumb ($attribs, FALSE, '', TRUE, TRUE, $absUrl, $width, $height);
}
/**
* @deprecated 3.6
* @param $customPrice
* @param $currency
* @param $calculator
* @return string
*/
static function _getCustomPrice($customPrice, $currency, $calculator) {
if ((float)$customPrice) {
$price = strip_tags ($currency->priceDisplay ($calculator->calculateCustomPriceWithTax ($customPrice)));
if ($customPrice >0) {
$price ="+".$price;
}
}
else {
$price = ($customPrice === '') ? '' : vmText::sprintf('COM_VIRTUEMART_CART_PRICE_FREE',$currency->getSymbol());
}
return $price;
}
static function renderCustomfieldPrice($productCustom,$product,$calculator){
if(!empty($productCustom->multiplyPrice) and $productCustom->multiplyPrice == 'free'){
$customPrice = '';
} else {
$customPrice = self::getCustomFieldPriceModificator($productCustom,$product);
}
if ( (float)$customPrice) {
if ($customPrice > 0) {
$sign = vmText::_('COM_VM_PLUS');
} else {
$sign = vmText::_('COM_VM_MINUS');
}
$calculator->setProduct($product);
$priceV = $calculator->calculateCustomPriceWithTax ($customPrice);
$priceV = strip_tags ($calculator->_currencyDisplay->priceDisplay ( $priceV ));
if ($customPrice < 0) {
$priceV = trim($priceV,'-');
}
if(empty($productCustom->multiplyPrice)){
$price = vmText::sprintf('COM_VM_CUSTOMFIELD_VARIANT_PRICE',$sign,$priceV);
} else {
$v = trim($productCustom->customfield_price,0);
$v = trim($v,'.');
$price = vmText::sprintf('COM_VM_CUSTOMFIELD_VARIANT_PERCENTAGE',$sign,$v,$priceV);
}
}
else {
$price = ($customPrice === '') ? '' : vmText::sprintf('COM_VIRTUEMART_CART_PRICE_FREE',$calculator->_currencyDisplay->getSymbol());
}
return $price;
}
static function getCustomFieldPriceModificator($productCustom,$product){
if(empty($productCustom->multiplyPrice)){
$p = 0.0;
if($productCustom->field_type == 'PB'){
$p = floatval(VmModel::getModel('product')->getProduct($productCustom->bundle_product_id)->prices['product_price']);
}
$p += floatval($productCustom->customfield_price);
} else {
$product->modificatorSum = floatval($product->modificatorSum);
if($productCustom->multiplyPrice == 'base_productprice' or $productCustom->multiplyPrice == 'base_variantprice') {
if ($productCustom->field_type == 'PB') {
$pVirt = VmModel::getModel('product')->getProduct($productCustom->bundle_product_id)->prices['product_price'];
} else {
$pVirt = $product->allPrices[$product->selectedPrice]['product_price'];
}
//vmdebug('my virtual costs', $pVirt);
if ($productCustom->multiplyPrice == 'base_variantprice') {
$pVirt += $product->modificatorSum;
}
$pVirt = floatval($pVirt);
$productCustom->customfield_price = floatval($productCustom->customfield_price);
if ($productCustom->field_type == 'PB') {
$p = $pVirt + $pVirt * $productCustom->customfield_price * 0.01;
} else {
$p = $pVirt * $productCustom->customfield_price * 0.01;
}
} else if($productCustom->multiplyPrice == 'free'){
$p = 0.0;
} else { //base_modificatorprice
$p = $product->modificatorSum * $productCustom->customfield_price * 0.01;
}
}
return $p;
}
/**
* @param $product
* @param $variants ids of the selected variants
* @return float
*/
public function calculateModificators(&$product, $cart = null) {
if (!isset($product->modificatorSum)){
$product->modificatorSum = 0.0;
if(!empty($product->customfields)) {
foreach( $product->customfields as $k => $productCustom ) {
$selected = -1;
if(isset($product->cart_item_id)) {
if($cart === null) $cart = VirtueMartCart::getCart();
if(isset($cart->cartProductsData[$product->cart_item_id]['customProductData'][$productCustom->virtuemart_custom_id][$productCustom->virtuemart_customfield_id])) {
$selected = $cart->cartProductsData[$product->cart_item_id]['customProductData'][$productCustom->virtuemart_custom_id][$productCustom->virtuemart_customfield_id];
} else if(isset($cart->cartProductsData[$product->cart_item_id]['customProductData'][$productCustom->virtuemart_custom_id])) {
if($cart->cartProductsData[$product->cart_item_id]['customProductData'][$productCustom->virtuemart_custom_id] == $productCustom->virtuemart_customfield_id) {
$selected = $productCustom->virtuemart_customfield_id; //= 1;
}
} else if(isset ($product->customProductData[$productCustom->virtuemart_custom_id][$productCustom->virtuemart_customfield_id])){
$selected = $product->customProductData[$productCustom->virtuemart_custom_id][$productCustom->virtuemart_customfield_id];
}
} else {
$pluginFields = vRequest::getVar( 'customProductData', false );
if($pluginFields == false and isset($product->customPlugin)) {
$pluginFields = vmJsApi::safe_json_decode( $product->customPlugin, TRUE );
}
if(isset($pluginFields[$product->virtuemart_product_id][$productCustom->virtuemart_custom_id][$productCustom->virtuemart_customfield_id])) {
$selected = $pluginFields[$product->virtuemart_product_id][$productCustom->virtuemart_custom_id][$productCustom->virtuemart_customfield_id];
} else if(isset($pluginFields[$product->virtuemart_product_id][$productCustom->virtuemart_custom_id])) {
if($pluginFields[$product->virtuemart_product_id][$productCustom->virtuemart_custom_id] == $productCustom->virtuemart_customfield_id) {
$selected = 1;
}
}
}
if($selected === -1) {
continue;
}
if(!empty($productCustom) and $productCustom->field_type == 'E') {
vDispatcher::importVMPlugins( 'vmcustom' );
vDispatcher::trigger( 'plgVmPrepareCartProduct', array(&$product, &$product->customfields[$k], $selected, &$product->modificatorSum) );
} else {
if($productCustom->customfield_price) {
$product->modificatorSum += self::getCustomFieldPriceModificator($productCustom,$product);
}
}
}
}
}
return $product->modificatorSum;
}
/** Save and delete from database
* all product custom_fields and xref
@ var $table : the xref table(eg. product,category ...)
@array $data : array of customfields
@int $id : The concerned id (eg. product_id)
*/
public function storeProductCustomfields($table, $datas, $id) {
vRequest::vmCheckToken('Invalid token in storeProductCustomfields');
//Sanitize id
$id = (int)$id;
//Table whitelist
$tableWhiteList = array('product','category','manufacturer');
if(!in_array($table,$tableWhiteList)) return false;
// Get old IDS
$db = JFactory::getDBO();
$db->setQuery( 'SELECT * FROM `#__virtuemart_'.$table.'_customfields` as `PC` WHERE `PC`.virtuemart_'.$table.'_id ='.$id );
$oldCustomfields = $db->loadAssocList('virtuemart_customfield_id');
$old_customfield_ids = array_keys($oldCustomfields);
if (!empty( $datas['field'])) {
foreach($datas['field'] as $key => $fields){
if(!empty($datas['field'][$key]['virtuemart_product_id']) and (int)$datas['field'][$key]['virtuemart_product_id']!=$id){
//vmdebug('The field is from the parent',$fields);
$fields['override'] = !empty($fields['override'])?(int)$fields['override']:0;
$fields['disabler'] = !empty($fields['disabler'])?(int)$fields['disabler']:0;
if($fields['override']!=0 or $fields['disabler']!=0){
if($fields['override']!=0){
$fields['override'] = $fields['virtuemart_customfield_id'];
}
if($fields['disabler']!=0){
$fields['disabler'] = $fields['virtuemart_customfield_id'];
}
if(!empty($fields['virtuemart_customfield_id']) and empty($oldCustomfields[$fields['virtuemart_customfield_id']]['virtuemart_customfield_id'])){
//vmdebug('It is set now as override, store it as clone, therefore set the virtuemart_customfield_id = 0');
$fields['virtuemart_customfield_id'] = 0;
}
}
else {
//vmdebug('there is no override/disabler set',$fields,$oldCustomfields[$fields['virtuemart_customfield_id']]);
//we do not store customfields inherited by the parent, therefore
$key = array_search($fields['virtuemart_customfield_id'], $old_customfield_ids );
if ($key !== false ){
unset( $old_customfield_ids[ $key ] );
}
continue;
}
}
else {
//vmdebug('The field is from the current product',$fields);
if(empty($fields['override']) and empty($fields['disabler']) and !empty($fields['virtuemart_customfield_id']) and (!empty($oldCustomfields[$fields['virtuemart_customfield_id']]['disabler']) or !empty($oldCustomfields[$fields['virtuemart_customfield_id']]['override']) )){
//vmdebug('Remove customfield override/disabler',$fields['virtuemart_customfield_id']);
$old_customfield_ids[] = $fields['virtuemart_customfield_id'];
}
}
if(!empty($fields['field_type']) and $fields['field_type']=='C' and !isset($datas['clone']) ){
$cM = VmModel::getModel('custom');
$c = $cM->getCustom($fields['virtuemart_custom_id'],'');
if(!empty($fields['set_matrix'])){
$productModel = VmModel::getModel ('product');
$avail = $productModel->getProductChildIds($id);
foreach($fields['selectoptions'] as $kv => $selectoptions){
if(!empty($selectoptions['values'])){
$values[$kv] = preg_split('/\r\n|\r|\n/', $selectoptions['values'],5);
}
}
vmdebug('my values',$values,$avail);
$parentCombo = $fields['options'][$id];
$myMatrix = array();
$size = 1;
//$parentMatrix = array();
//Yes, also this may get better written, but I am just happy that it works this way.
foreach ($values as $variantKey => $optArray) {
$size = $size * sizeof($optArray);
//$level++;
foreach ($optArray as $option) {
//vmdebug('myMatrix $k=>$option',$option);
if($variantKey==0){
$myMatrix[$option] = null;
//$parentMatrix[$parentCombo[0]] = null;
} else if($variantKey == 1){
$myMatrix = self::writeValuesToKeysAddValueArray($myMatrix,$option);
//$parentMatrix[$parentCombo[0]][$parentCombo[1]]= null;
} else if($variantKey == 2){
foreach($myMatrix as $k1 => &$option1){
$option1 = self::writeValuesToKeysAddValueArray($option1,$option);
}
//$parentMatrix[$parentCombo[0]][$parentCombo[1]][$parentCombo[2]]= null;
} else if($variantKey == 3){
foreach($myMatrix as $k1 => &$option1){
foreach($option1 as $k2 => &$option2){
$option2 = self::writeValuesToKeysAddValueArray($option2,$option);
}
}
//$parentMatrix[$parentCombo[0]][$parentCombo[1]][$parentCombo[2]][$parentCombo[3]]= null;
} else if($variantKey == 4){
foreach($myMatrix as $k1 => &$option1){
foreach($option1 as $k2 => &$option2){
foreach($option2 as $k3 => &$option3){
$option3 = self::writeValuesToKeysAddValueArray($option3,$option);
}
}
}
//$parentMatrix[$parentCombo[0]][$parentCombo[1]][$parentCombo[2]][$parentCombo[3]][$parentCombo[4]]= null;
}
}
}
vmdebug('myMatrix 3',$size,$myMatrix);
vmdebug('myMatrix orig $fields',$fields['options']);
$parentComboSerialized = serialize($parentCombo);
//reset($avail);
for((int)$i=0;$i<$size;$i++){
if(empty($avail)){
$childId = $productModel->createChild($id);
} else {
$childId = $avail[$i];
unset($avail[$i]);
}
vmdebug('$childId after unset'.$i,$childId,$avail);
$combo = self::writeCombos($myMatrix);
if(serialize($combo) == $parentComboSerialized){
$combo = self::writeCombos($myMatrix);
//vmdebug('myMatrix $combo equals $parentCombo',$combo, $parentCombo);
$size--;
} else {
//vmdebug('myMatrix $combo NOT equal',serialize($combo), $parentComboSerialized);
}
$fields['options'][$childId] = $combo;
}
vmdebug('myMatrix $fields',$fields['options'],$avail);
}
//The idea was here to store the images directly. Maybe just the ids.
/*if(!empty($c->withImage)){
$mediaM = VmModel::getModel('media');
$tablePM = $mediaM->getTable('product_medias');
foreach($fields['options'] as $prodId => $lvalue){
$images = $tablePM->load($prodId);
if(isset($images[0])){
$media = $mediaM->createMediaByIds($images[0]);
$fields['images'][$prodId] = $media[0]->getFileUrlThumb();
}
}
}*/
//Set tags on extra customfield
if(!empty($c->sCustomId)){
$sCustId = $c->sCustomId;
$labels = array();
foreach($fields['selectoptions'] as $k => $option){
if (is_object($option)) {
$option = Joomla\Utilities\ArrayHelper::fromObject($option);
}
if($option['voption'] == 'clabels' and !empty($option['clabel'])){
$labels[$k] = $option['clabel'];
}
}
foreach($fields['options'] as $prodId => $lvalue){
if($prodId == $id) continue;
$db->setQuery( 'SELECT `virtuemart_customfield_id` FROM `#__virtuemart_'.$table.'_customfields` as `PC` WHERE `PC`.virtuemart_'.$table.'_id ="'.$prodId.'" AND `virtuemart_custom_id`="'.(int)$sCustId.'" ' );
$strIds = $db->loadColumn();
$i=0;
foreach($lvalue as $k=>$value) {
if(!empty($labels[$k])) {
$ts = array();
$ts['field_type'] = 'S';
$ts['virtuemart_product_id'] = (int)$prodId;
$ts['virtuemart_custom_id'] = (int)$sCustId;
if(isset($strIds[$i])){
$ts['virtuemart_customfield_id'] = (int)$strIds[$i];
unset( $strIds[$i++] );
}
$ts['customfield_value'] = $value;
$tableCustomfields = $this->getTable($table.'_customfields');
$tableCustomfields->bindChecknStore($ts);
}
}
if(count($strIds)>0){
// delete old unused Customfields
$db->setQuery( 'DELETE FROM `#__virtuemart_'.$table.'_customfields` WHERE `virtuemart_customfield_id` in ("'.implode('","', $strIds ).'") ');
$db->execute();
}
}
}
//vmdebug('Executing',$id,$fields);
}
if (!empty($datas['customfield_params'][$key]) and !isset($datas['clone']) ) {
if (array_key_exists( $key,$datas['customfield_params'])) {
$fields = array_merge ((array)$fields, (array)$datas['customfield_params'][$key]);
}
}
$fields['virtuemart_'.$table.'_id'] = $id;
if(!empty($fields['field_type']) and ( $fields['field_type']=='RC' or $fields['field_type']=='R' ) and !isset($datas['clone']) ){
if(is_array($fields['customfield_value'])){
$fields['customfield_value'] = implode(',',$fields['customfield_value']);
}
}
$this->storeProductCustomfield('product', $fields);
$datas['field'][$key] = $fields;
$keyOld = array_search($fields['virtuemart_customfield_id'], $old_customfield_ids );
if ($keyOld !== false ) unset( $old_customfield_ids[ $keyOld ] );
}
} else {
//vmdebug('storeProductCustomfields nothing to store');
}
vDispatcher::importVMPlugins('vmcustom');
//vmdebug('Delete $old_customfield_ids',$old_customfield_ids);
if ( count($old_customfield_ids) ) {
// call the plugins to delete their records
foreach ($old_customfield_ids as $old_customfield_id) {
vDispatcher::trigger('plgVmOnCustomfieldRemove', array($oldCustomfields[$old_customfield_id]));
}
// delete old unused Customfields
$db->setQuery( 'DELETE FROM `#__virtuemart_'.$table.'_customfields` WHERE `virtuemart_customfield_id` in ("'.implode('","', $old_customfield_ids ).'") ');
$db->execute();
//vmdebug('Deleted $old_customfield_ids',$old_customfield_ids);
}
if (isset($datas['customfield_params']) and is_array($datas['customfield_params'])) {
foreach ($datas['field'] as $key => $pfield ) {
if($pfield['field_type']=="E" and !empty($pfield['custom_element'])){
vDispatcher::directTrigger( 'vmcustom',$pfield['custom_element'], 'plgVmOnStoreProduct', array($datas, $datas['customfield_params'][$key], $old_customfield_ids, $key ));
}
}
}
}
static public function writeValuesToKeysAddValueArray($myMatrix,$option){
$myMatrix1 = $myMatrix;
foreach($myMatrix as $k=>$option1){
$myMatrix1[$k][$option] = null;
}
return $myMatrix1;
}
/**
* This function creates the different combinations for the Multivariants.
* Yes, this function could be written more abstract and smarter, but so long any tries took almost the same size and were not working.
* @author Max Milbers
* @param $myMatrix
* @return array
*/
static public function writeCombos(&$myMatrix){
$comboArray = array();
foreach($myMatrix as $option => $options){
$comboArray[] = $option; //1
if(is_array($options) and !empty($options)){
foreach($options as $option1 => $options1){
$comboArray[] = $option1; //2
if(is_array($options1) and !empty($options1)){
foreach($options1 as $option2 => $options2){
$comboArray[] = $option2; //3
if(is_array($options2) and !empty($options2)){
foreach($options2 as $option3 => $options3){
$comboArray[] = $option3; //4
if(is_array($options3) and !empty($options3)){
foreach($options3 as $option4 => $options4) {
$comboArray[] = $option4; //5
unset($myMatrix[$option][$option1][$option2][$option3][$option4]);
if(empty($myMatrix[$option][$option1][$option2][$option3])){
unset($myMatrix[$option][$option1][$option2][$option3]);
if(empty($myMatrix[$option][$option1][$option2])){
unset($myMatrix[$option][$option1][$option2]);
if(empty($myMatrix[$option][$option1])){
unset($myMatrix[$option][$option1]);
if(empty($myMatrix[$option])){
unset($myMatrix[$option]);
}
}
}
}
vmdebug('level 5', $comboArray);
return $comboArray;
}
} else {
unset($myMatrix[$option][$option1][$option2][$option3]);
if(empty($myMatrix[$option][$option1][$option2])){
unset($myMatrix[$option][$option1][$option2]);
if(empty($myMatrix[$option][$option1])){
unset($myMatrix[$option][$option1]);
if(empty($myMatrix[$option])){
unset($myMatrix[$option]);
}
}
}
vmdebug('level 4', $comboArray);
return $comboArray;
}
}
} else {
unset($myMatrix[$option][$option1][$option2]);
if(empty($myMatrix[$option][$option1])){
unset($myMatrix[$option][$option1]);
if(empty($myMatrix[$option])){
unset($myMatrix[$option]);
}
}
vmdebug('level 3', $comboArray);
return $comboArray;
}
}
} else {
unset($myMatrix[$option][$option1]);
if(empty($myMatrix[$option])){
unset($myMatrix[$option]);
}
//vmdebug('level 2', $option, $comboArray);
return $comboArray;
}
}
} else {
unset($myMatrix[$option]);
vmdebug('level 1', $option, $comboArray);
return $comboArray;
}
}
}
public function storeProductCustomfield($table, &$fields){
$tableCustomfields = $this->getTable($table.'_customfields');
$tableCustomfields->_xParams = 'customfield_params';
VirtueMartModelCustom::setParameterableByFieldType($tableCustomfields,$fields['field_type'],$fields['custom_element'],$fields['custom_jplugin_id']);
//We do not store default values
$paramsTemp = array();
foreach($tableCustomfields->_varsToPushParam as $name=>$attrib){
if(isset($fields[$name])){
$paramsTemp[$name] = $attrib;
} else {
unset($tableCustomfields->{$name});
}
}
$tableCustomfields->_varsToPushParam = $paramsTemp;
$tableCustomfields->bindChecknStore($fields);
}
static public function setEditCustomHidden ($customfield, $i) {
if (!isset($customfield->virtuemart_customfield_id))
$customfield->virtuemart_customfield_id = '0';
if (!isset($customfield->virtuemart_product_id))
$customfield->virtuemart_product_id = '';
$html = '
';
$html .= '';
return $html;
}
private $_hidden = array();
public function addHidden ($name, $value = '') {
$this->_hidden[$name] = $value;
}
}
// pure php no closing tag