News:

Looking for documentation? Take a look on our wiki

Main Menu

Custom fields hidden on Product Details [solved]

Started by szmidt344, February 04, 2015, 14:43:44 PM

Previous topic - Next topic

szmidt344

Hey guys!

Im feeling so close to resolve my problem, but its still getting errors.

So I would like to show custom fields on product details page, but only few products have this option.
This code works only for products with custom field:

<?php
$custom_title 
null;
foreach (
$this->product->customfieldsSorted['normal'] as $field) { 
if ( 
$field->is_hidden )
continue;
if (
$field->display) {
?>

<span class="product-field-display"><?php echo $field->display; }} ?></span>


If product hasn't custom field it shows
QuoteWarning: Invalid argument supplied for foreach() in

Any idea?

GJC Web Design



<?php
$custom_title 
null;
if(
$this->product->customfieldsSorted['normal']){
     foreach (
$this->product->customfieldsSorted['normal'] as $field) { 
        if ( 
$field->is_hidden )
      continue;
            if (
$field->display) { ?>

                <span class="product-field-display"><?php echo $field->display; </span>
             }
        } 
    }
?>


GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

szmidt344

Quote from: GJC Web Design on February 04, 2015, 22:24:09 PM


<?php
$custom_title 
null;
if(
$this->product->customfieldsSorted['normal']){
     foreach (
$this->product->customfieldsSorted['normal'] as $field) { 
        if ( 
$field->is_hidden )
      continue;
            if (
$field->display) { ?>

                <span class="product-field-display"><?php echo $field->display; </span>
             }
        } 
    }
?>




Solved :) Thank You!