Custom field Generic Child Variant shows Option name instead of value in Cart

Started by Enriko, January 02, 2015, 13:58:41 PM

Previous topic - Next topic

Enriko

Dear all,

In the cart area the type of the Generic Child Variant is shown as value instead of the Value what is stored on this field of the child product.

In green is the selected product
in Orange is the used customfield (title)
In Red is the used option in the product.

I did the following:
I installed a site with the sample data.
I selected a child product of this product http://baby.16mb.com/default-products/product-generic-child-variant-detail
The result is shown in the cart as above.

After some searching i found out the code which i assume is filling this data.
In the file administrator/components/com_virtuemart/models/customfields.php starting from line 1162 but the affected line starts at 1193
else {
$value = vmText::_($productCustom->customfield_value);
}
$trTitle = vmText::_($productCustom->custom_title);
if($productCustom->custom_title!=$trTitle and strpos($trTitle,'%1')!==false){
$html .= vmText::sprintf($productCustom->custom_title,$value);
} else {
$html .= $trTitle.' '.$value;
}


The trTitle is fetched correctly from the customs fields
The value is taken from the customfield_value from the table virtuemart_product_customfields


But this is the option you can select in the product custom field type.


What i would like to have changed is that there will be a new code for above. Which will retrieve the real value for this kind of type for the corresponding product child.

  • 'product_name' = #_virtuemart_products_xx_xx.product_name
  • 'product_sku' = #_virtuemart_products.product_sku
  • 'slug' = #_virtuemart_products_xx_xx.slug
  • 'product_length' = #_virtuemart_products.product_length
  • 'product_width' = #_virtuemart_products.product_width
  • 'product_height' = #_virtuemart_products.product_height
  • 'product_weight' = #_virtuemart_products.product_weight

i assume there can be a code which looks which type it is and then searches for the correct value based on the correct table like:
elseif (($productCustom->field_type == "A")) {
switch ($productCustom->customfield_value); {
case 'product_name':
$ value = Select #_virtuemart_products_xx_xx.product_name where virtuemart_product_id = selected child id
break
case 'product_sku':
$ value = Select #_virtuemart_products.product_sku where virtuemart_product_id = selected child id
break
etc.. till all options are done

/** the rest as default */
$trTitle = vmText::_($productCustom->custom_title);
if($productCustom->custom_title!=$trTitle and strpos($trTitle,'%1')!==false){
$html .= vmText::sprintf($productCustom->custom_title,$value);
} else {
$html .= $trTitle.' '.$value;
}


This will show the correct value after the customfield title. The value will be the one also shown in the product selection drop down.


Would it be possible to have this model updated? So that the correct value is shown in the cart. (egual to the fields in the dropdown-list as shown above)
Thanks for your support

Enriko

VirtueMart       3.0.2
Joomla!            3.3.6   
PHP Version   5.3.29

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/