/** * 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 * */ public function customFieldDisplay($product, $variantmods, $html, $trigger) { //vmdebug('customFieldDisplay $variantmods',$variantmods); $row = 0; if (!class_exists('shopFunctionsF')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } foreach ($variantmods as $selected => $variant) { if ($selected) { $productCustom = self::getProductCustomFieldCart($selected); if (!empty($productCustom)) { $html .= ' <span class="product-field-type-' . $productCustom->field_type . '">'; if ($productCustom->field_type == "E") { $product = self::addParam($product); $product->productCustom = $productCustom; //vmdebug('CustomsFieldCartDisplay $productCustom',$productCustom); // vmdebug('customFieldDisplay $product->param selected '.$selected,$product->param); if (!class_exists('vmCustomPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php'; } JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger($trigger, array($product, $row, &$html)); } else { $value = ''; if ($productCustom->field_type == "G") { $child = self::getChild($productCustom->custom_value); // $html .= $productCustom->custom_title.' '.$child->product_name; $value = $child->product_name; } elseif ($productCustom->field_type == "M") { // $html .= $productCustom->custom_title.' '.self::displayCustomMedia($productCustom->custom_value); $value = self::displayCustomMedia($productCustom->custom_value); } elseif ($productCustom->field_type == "S") { // q $html .= $productCustom->custom_title.' '.JText::_($productCustom->custom_value); $value = $productCustom->custom_value; } else { // $html .= $productCustom->custom_title.' '.$productCustom->custom_value; $value = $productCustom->custom_value; } $html .= ShopFunctionsF::translateTwoLangKeys($productCustom->custom_title, $value); } $html .= '</span><br />'; } else { // falldown method if customfield are deleted foreach ((array) $selected as $key => $value) { $html .= '<br/ >' . ($key ? '<span>' . $key . ' </span>' : '') . $value; } vmdebug('CustomsFieldOrderDisplay, $item->productCustom empty? ' . $variant); vmdebug('customFieldDisplay, $productCustom is EMPTY '); } } $row++; } vmdebug('customFieldDisplay html begin: ' . $html . ' end'); return $html . '</div>'; }
/** * 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 * */ public function customFieldDisplay($product, $variantmods, $html, $trigger) { //vmdebug('customFieldDisplay $variantmods',$variantmods); $row = 0; JLoader::register('shopFunctionsF', JPATH_VM_SITE . '/helpers/shopfunctionsf.php'); //MarkerVarMods foreach ($variantmods as $selected => $variant) { //foreach ($variantmods as $variant=> $selected) { //vmdebug('customFieldDisplay '.$variant.' '.$selected); if ($selected) { $productCustom = self::getProductCustomField($selected); //vmdebug('customFieldDisplay',$selected,$productCustom); if (!empty($productCustom)) { $html .= ' <span class="product-field-type-' . $productCustom->field_type . '">'; if ($productCustom->field_type == "E") { $product = self::addParam($product); $product->productCustom = $productCustom; //vmdebug('CustomsFieldCartDisplay $productCustom',$productCustom); // vmdebug('customFieldDisplay $product->param selected '.$selected,$product->param); JLoader::register('vmCustomPlugin', JPATH_VM_PLUGINS . '/vmcustomplugin.php'); JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger($trigger, array($product, $row, &$html)); } else { //vmdebug('customFieldDisplay $productCustom by self::getProductCustomField $variant: '.$variant.' $selected: '.$selected,$productCustom); $value = ''; if ($productCustom->field_type == "G") { $child = self::getChild($productCustom->custom_value); // $html .= $productCustom->custom_title.' '.$child->product_name; $value = $child->product_name; } elseif ($productCustom->field_type == "M") { // $html .= $productCustom->custom_title.' '.self::displayCustomMedia($productCustom->custom_value); $value = self::displayCustomMedia($productCustom->custom_value); } elseif ($productCustom->field_type == "S") { // q $html .= $productCustom->custom_title.' '.JText::_($productCustom->custom_value); $value = $productCustom->custom_value; } else { // $html .= $productCustom->custom_title.' '.$productCustom->custom_value; //vmdebug('customFieldDisplay',$productCustom); $value = $productCustom->custom_value; } $html .= ShopFunctionsF::translateTwoLangKeys($productCustom->show_title ? $productCustom->custom_title : '', $value); } $html .= '</span>'; //STUDIO 42 , removed <br/>, why simply not "div" and not "span" ? } else { // falldown method if customfield are deleted foreach ((array) $selected as $key => $value) { $html .= '<br/ >Couldnt find customfield' . ($key ? '<span>' . $key . ' </span>' : '') . $value; } } } $row++; } // vmdebug ('customFieldDisplay html begin: ' . $html . ' end'); return $html . '</div>'; }
/** * 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 * */ public static function displayProductCustomfieldSelected($product, $html, $trigger) { if (isset($product->param)) { vmTrace('param found, seek and destroy'); return false; } $row = 0; if (!class_exists('shopFunctionsF')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $variantmods = isset($product->customProductData) ? $product->customProductData : $product->product_attribute; if (empty($variantmods)) { $productDB = VmModel::getModel('product')->getProduct($product->virtuemart_product_id); if ($productDB) { $product->customfields = $productDB->customfields; } } if (!is_array($variantmods)) { $variantmods = json_decode($variantmods, true); } $productCustoms = array(); foreach ($product->customfields as $prodcustom) { //We just add the customfields to be shown in the cart to the variantmods if (is_object($prodcustom)) { if ($prodcustom->is_cart_attribute and !$prodcustom->is_input) { $variantmods[$prodcustom->virtuemart_custom_id] = $prodcustom->virtuemart_customfield_id; } else { if (!empty($variantmods) and !empty($variantmods[$prodcustom->virtuemart_custom_id])) { } } $productCustoms[$prodcustom->virtuemart_customfield_id] = $prodcustom; } } foreach ($variantmods as $custom_id => $customfield_ids) { if (!is_array($customfield_ids)) { $customfield_ids = array($customfield_ids => false); } foreach ($customfield_ids as $customfield_id => $params) { if (empty($productCustoms) or !isset($productCustoms[$customfield_id])) { continue; } $productCustom = $productCustoms[$customfield_id]; //The stored result in vm2.0.14 looks like this {"48":{"textinput":{"comment":"test"}}} //and now {"32":[{"invala":"100"}]} if (!empty($productCustom)) { $html .= ' <span class="product-field-type-' . $productCustom->field_type . '">'; if ($productCustom->field_type == "E") { //$product->productCustom = $productCustom; //$product->row = $row; // if (!class_exists('vmCustomPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php'; } JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); //vmdebug('displayProductCustomfieldSelected is PLUGIN use trigger '.$trigger,$product->virtuemart_product_id,$productCustom->virtuemart_customfield_id,$productCustom->custom_element); $dispatcher->trigger($trigger . 'VM3', array(&$product, &$productCustom, &$html)); } else { //vmdebug('customFieldDisplay $productCustom by self::getProductCustomField $variant: '.$variant.' $selected: '.$selected,$productCustom); $value = ''; if ($productCustom->field_type == "G") { $db = JFactory::getDBO(); $db->setQuery('SELECT `product_name` FROM `#__virtuemart_products_' . VmConfig::$vmlang . '` WHERE virtuemart_product_id=' . (int) $productCustom->customfield_value); $child = $db->loadObject(); $value = $child->product_name; } elseif ($productCustom->field_type == "M") { // $html .= $productCustom->custom_title.' '.self::displayCustomMedia($productCustom->custom_value); $value = self::displayCustomMedia($productCustom->customfield_value); } elseif ($productCustom->field_type == "S") { //$value = $productCustom->custom_title.' '.vmText::_($productCustom->customfield_value); $value = $productCustom->customfield_value; } else { // $html .= $productCustom->custom_title.' '.$productCustom->custom_value; //vmdebug('customFieldDisplay',$productCustom); $value = $productCustom->customfield_value; } $html .= ShopFunctionsF::translateTwoLangKeys($productCustom->custom_title, $value); } $html .= '</span><br />'; } else { // falldown method if customfield are deleted foreach ((array) $customfield_id as $key => $value) { $html .= '<br/ >Couldnt find customfield' . ($key ? '<span>' . $key . ' </span>' : '') . $value; } //vmdebug ('CustomsFieldOrderDisplay, $item->productCustom empty? ' . $variant); vmdebug('customFieldDisplay, $productCustom is EMPTY ' . $customfield_id); } } } return $html . '</div>'; }