News:

Looking for documentation? Take a look on our wiki

Main Menu

Does "CustomsFieldOrderDisplay" work properly?

Started by carlos.alonso, December 02, 2014, 18:27:25 PM

Previous topic - Next topic

carlos.alonso

Hi,

I am using VM 2.06 on Joomla 1.7. I know everything is very old but it is not up tome to upgrade.

My problem is that the custom fields are not properly printed in the invoices. The title is ok ut the vaule of the custom field is not displayed.

Checking views/invoice i came to "administrator/components/com_virtuemart/models/customfields.php", and then the function that prints in html is "CustomsFieldOrderDisplay".
I found that for sotckable variants (field_type = "E"), there was no code, but i have copied it from a more modern version of the file (hoping it doesn´t break anything and it looks like it doesn´t).

So this is the code i have and as said it is not printing more than the titles of the custom fields:

public function CustomsFieldOrderDisplay($item,$view='FE',$absUrl = false) {
$row = 0 ;
// $item=(array)$item;
if (!empty($item->product_attribute)) {
$item->param = json_decode($item->product_attribute,true);
$html = '<div class="vm-customfield-cart">';
if (!empty($item->param)) {
    // vmdebug('CustomsFieldOrderDisplay',$item->param);
    foreach ($item->param as $virtuemart_customfield_id=>$param){
    if ($param) {
    if ($item->productCustom = self::getProductCustomFieldCart ($virtuemart_customfield_id ) ) {
if(!class_exists('shopFunctionsF'))require(JPATH_VM_SITE.DS.'helpers'.DS.'shopfunctionsf.php');
// vmdebug('$param',$param);
$html .= ' <span class="product-field-type-'.$item->productCustom->field_type.'">';
$value ='';
    if ($item->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));
    } elseif ($item->productCustom->field_type == "G") {
    $child = self::getChild($item->productCustom->custom_value);
$value = $child->product_name;
} elseif ($item->productCustom->field_type == "M") {
$value = self::displayCustomMedia($item->productCustom->custom_value);
    } elseif (($item->productCustom->field_type == "S")) {
$value = $item->productCustom->custom_value;
}  else {
$value = $item->productCustom->custom_value;
    }
$html .=ShopFunctionsF::translateTwoLangKeys($item->productCustom->custom_title,$value);

$html .= '</span>';
    } else {
    // falldown method if customfield are deleted
    foreach((array)$param as $key => $value) {
$html .= '<br/ >'.($key?'<span>'.$key.' </span>':'').$value;
    }
    vmdebug('CustomsFieldOrderDisplay, $item->productCustom empty? '.$virtuemart_customfield_id);
    }
    }
    $row++;
    }
// if (!empty($item->param) and !empty($item->custom_value)) {

    if(!class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS.DS.'vmcustomplugin.php');
    JPluginHelper::importPlugin('vmcustom');
    $dispatcher = JDispatcher::getInstance();
    $dispatcher->trigger('plgVmDisplayInOrder'.$view,array( $item, $row, &$html));
} else {
vmdebug('CustomsFieldOrderDisplay $item->param empty? ');
}
return $html.'</div> ';
} else {
// vmTrace('$item->product_attribut is empty');
}
return '';
}