VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: chabi01 on April 21, 2020, 14:28:51 PM

Title: Issue with simple and double quote in customfield variant (children products)
Post by: chabi01 on April 21, 2020, 14:28:51 PM
Hi,
When i have children product with a simple quote in the name (should be the same with double quote), then in the "dropdown list", i find html entities and also if i select the product in the list.

Check this page to see  the issue : http://biosource2020.xlcrea373030.com/isolation/coton-lin-chanvre-en-panneaux/panneau-isolant-en-chanvre-coton-et-lin-biofib-trio-detail.html
The parent product have a correct quote in his name, but check the children product in the dropdown, and select one in the dropdown...

How can i solve this ? Please, if i have to modifiy the php code, give me the file name and the code to change (to avoid me to make a big mess in the files..).

Thanks a lot for the help :)

Xavier
Title: Re: Issue with simple and double quote in customfield variant (children products)
Post by: chabi01 on April 21, 2020, 14:29:29 PM
For the record : very last Joomla and very last VM versions.
Xavier
Title: Re: Issue with simple and double quote in customfield variant (children products)
Post by: Studio 42 on April 21, 2020, 17:51:05 PM
You need certainly to encode the value.
See in virtuemart/layout/customfields.php
Note the you can override the layout in your template, to not loose the changes
Title: Re: Issue with simple and double quote in customfield variant (children products)
Post by: chabi01 on April 21, 2020, 23:56:01 PM
Hi,
Thanks, but how to do this ? Can somebody can help me for the code to change here ? I have checked the customfields.php file but i dont find where to change the code here...

Thanks :)

Xavier
Title: Re: Issue with simple and double quote in customfield variant (children products)
Post by: Studio 42 on April 22, 2020, 00:29:25 AM
Exact file is components/com_virtuemart/sublayouts/customfield.php
   case 'A':

   $options[] = array('value' => JRoute::_ ('index.php?option=com_virtuemart&view='.$view.'&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $productChild->virtuemart_product_id,false), 'text' => $productChild->{$customfield->customfield_value}.$priceStr);

The problem is in
$productChild->{$customfield->customfield_value}
Title: Re: Issue with simple and double quote in customfield variant (children products)
Post by: chabi01 on April 22, 2020, 10:36:31 AM
Hi,
I tried this :

$options[] = array('value' => JRoute::_ ('index.php?option=com_virtuemart&view='.$view.'&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $productChild->virtuemart_product_id,false), htmlspecialchars_decode('text' => $productChild->{$customfield->customfield_value}).$priceStr);


but this generate an error.
How to solve this... I shouldn't not be the only one who have this issue : as in France we use a lot of quote in name and as for a tv shop you can have some " as 32" for size, anybody did solve this before ?

Thanks a lot for the help :)
Xavier
Title: Re: Issue with simple and double quote in customfield variant (children products)
Post by: pinochico on April 22, 2020, 10:40:21 AM
hmmm,

Im not programmer, but I think you must use decode right by variable (not for all in bracket) = is logical

htmlspecialchars_decode('text' => $productChild->{$customfield->customfield_value}

better

'text' => htmlspecialchars_decode($productChild->$customfield->customfield_value)}
Title: Re: Issue with simple and double quote in customfield variant (children products)
Post by: Studio 42 on April 22, 2020, 10:41:31 AM
Try htmlspecialchars_encode
Title: Re: Issue with simple and double quote in customfield variant (children products)
Post by: chabi01 on April 22, 2020, 11:43:47 AM
Thanks :)

Works now :)

Have a nice day "Studio42" ;)

Xavier