VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: andrey on May 03, 2012, 09:14:15 AM

Title: [Bug] Custom field title appears twice
Post by: andrey on May 03, 2012, 09:14:15 AM
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]
Title: Re: [Bug] Custom field title appears twice
Post by: andrey on May 03, 2012, 10:41:50 AM
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.
Title: Re: [Bug] Custom field title appears twice
Post by: Milbo on May 03, 2012, 11:23:08 AM
haha funny, I fixed this also yesterday. Please check the latest svn or the new version of today.
Title: Re: [Bug] Custom field title appears twice
Post by: andrey on May 03, 2012, 11:35:53 AM
Great! Thanks! Is 2.0.7 (http://forum.virtuemart.net/index.php?topic=102143.0) the latest?
Title: Re: [Bug] Custom field title appears twice
Post by: Milbo on May 03, 2012, 11:54:37 AM
It will be in 2.0.7a
Title: Re: [Bug] Custom field title appears twice
Post by: andrey on May 03, 2012, 12:09:47 PM
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".
Title: Re: [Bug] Custom field title appears twice
Post by: Actlas on May 19, 2012, 18:22:16 PM
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...
Title: Re: [Bug] Custom field title appears twice
Post by: Milbo on May 20, 2012, 19:49:47 PM
Okey, rechecked. Please test.
Title: Re: [Bug] Custom field title appears twice
Post by: Actlas on May 21, 2012, 08:40:32 AM
Which files should I update now? Using the SVN repository, or how?
Title: Re: [Bug] Custom field title appears twice
Post by: Actlas on May 24, 2012, 18:38:09 PM
Milbo, could you please tell me what exactly should be updated and how?
We cannot simply update our entire website at this moment.
Title: Re: [Bug] Custom field title appears twice
Post by: kfirc3 on June 07, 2012, 20:24:18 PM
can you guide me how to fix that ?
Title: Re: [Bug] Custom field title appears twice
Post by: dirkb on July 31, 2012, 17:54:24 PM
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.
Title: Re: [Bug] Custom field title appears twice
Post by: chetanmadaan on September 12, 2012, 02:33:07 AM
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
Title: Re: [Bug] Custom field title appears twice
Post by: fishbones on December 23, 2012, 18:42:00 PM
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!!!

:-\
Title: Re: [Bug] Custom field title appears twice
Post by: Milbo on December 23, 2012, 18:45:19 PM
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.
Title: Re: [Bug] Custom field title appears twice
Post by: fishbones on December 23, 2012, 18:57:29 PM
many thanks for your answer.  :)
we are using the plugin that has been installed together with VM2.

how can this be solved for the time being?

cheers