News:

Support the VirtueMart project and become a member

Main Menu

[Bug] Custom field title appears twice

Started by andrey, May 03, 2012, 09:14:15 AM

Previous topic - Next topic

andrey

I've added a custom field to the product - 'Custom Field Text Input' plugin. And the field title appears twice in the cart.

[attachment cleanup by admin]

andrey

This code is from customfields.php in CustomsFieldCartDisplay function:
foreach ($variantmods as $variant=>$selected){
if ($selected) {
$productCustom = self::getProductCustomFieldCart ($selected );
if(!empty($productCustom)){
$html .= ' <span class="product-field-type-'.$productCustom->field_type.'">';
$value ='';
if ($productCustom->field_type == "E") {

} elseif (($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>';
} else {
vmdebug('CustomsFieldCartDisplay, $productCustom is empty ');
}

}
$row++;
}
if ($variantmods ) {
$product = self::addParam($product);
if(!class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS.DS.'vmcustomplugin.php');
JPluginHelper::importPlugin('vmcustom');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('plgVmOnViewCart',array($product, $row,&$html));

}


You see, that we add html code for every field, including the plugin type (E) fields:
$html .=ShopFunctionsF::translateTwoLangKeys($productCustom->custom_title,$value);
And after that, we trigger 'plgVmOnViewCart' and custom plugin itself add its value to html:
$dispatcher->trigger('plgVmOnViewCart',array($product, $row,&$html));

That is why we got title appears twice. I think we need to skip E-type fields in the loop and don't add any html code for them.

Milbo

haha funny, I fixed this also yesterday. Please check the latest svn or the new version of today.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

andrey


Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

andrey

Just checked th SVN. Don't you think we mess up <span> tags here? We add open tag, and continue without closing it:
$html .= ' <span class="product-field-type-'.$productCustom->field_type.'">';
$value ='';
if ($productCustom->field_type == "E") {
continue;
} elseif (($productCustom->field_type == "G")) {
...
} else {
// $html .= $productCustom->custom_title.' '.$productCustom->custom_value;
$value = $productCustom->custom_value;
}
$html .=ShopFunctionsF::translateTwoLangKeys($productCustom->custom_title,$value);
$html .= '</span><br />';


$html .= ' <span class="product-field-type-'.$productCustom->field_type.'">'; - will add start <span> tag, but the closing tag for the <span> would not be added if $productCustom->field_type == "E".

Actlas

Sorry for repeating this question in the forums but this field is still displayed twice in 2.0.7c.

The biggest problem is although it is displayed twice in the cart it doesn't get added to the order in VM itself.
You can see the values in the DB though...

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Actlas

Which files should I update now? Using the SVN repository, or how?

Actlas

Milbo, could you please tell me what exactly should be updated and how?
We cannot simply update our entire website at this moment.

kfirc3


dirkb

I checked a few weeks ago on that thread, since I have the same problem. As of today, I still have it with VM 2.0.8e - is there a solution for that ? Thanks d.

chetanmadaan

i am using 2.0.8e and i am having the same problem.

specifically, it doesn't comes up twice... but comes up the number of plugin custom fields we have published in the cart.

for instance if we have three custom fields... it would display all the cart variant fields three times

fishbones

Hi

We are having this Problem too.
We have setup some Costom stockable variants.
They do apear several times on my cart.
If a product has 3 Costom stockable variants, they apear 3 times.
If a product has 2 Costom stockable variants, they apear 2 times.
and so on...

any ideas hox to solve this problem?

We are working with:
Joomla! 2.5.7
VirtueMart 2.0.12


MANY THANKS FOR YOUR HELP!!!

:-\

Milbo

It must be done by the plugin itself atm, that is the problem. I think vm2.1 it will be solved. It is also solved now, but depends on the used plugin.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/