Skip to main content

Hide empty custom field from checkout cart

More
1 year 2 months ago #367836 by verzevoul
-- HikaShop version -- : 6.0.0
-- Joomla version -- : 3.10.12

Hi!

I added two product custom fields to the checkout cart.
I want to ask if it's possible to hide them if they have no value.
For example one field is in some products but not the other is not, so they are both in the cart but one column looks empty.

Thank you!

Please Log in or Create an account to join the conversation.

More
1 year 2 months ago #367843 by nicolas
Hi,

Try adding the code:
Code:
if(!empty($this->extraFields['product'])) { $remove = []; $config = hikashop_config(); $group = $config->get('group_options', 0); foreach($this->extraFields['product'] as $fieldname => $field) { $hide = true; foreach($products as $i => $product) { if(empty($product->cart_product_quantity)) continue; if($group && !empty($product->cart_product_option_parent_id)) continue; if(empty($product->$fieldname)) continue; $hide = false; } if($hide) { $remove[] = $i; } } if(count($remove)) { foreach($remove as $k) { unset($this->extraFields['product'][$k]); } } }
after the line:
Code:
$this->extraFields['product'] = $this->fieldClass->getFields('display:checkout=1', $products, 'product');
in the file components/com_hikashop/views/checkout/view.html.php
It should hopefully do it.
We can include this code on our end for the next version if it works fine.
The following user(s) said Thank You: verzevoul

Please Log in or Create an account to join the conversation.

Time to create page: 0.160 seconds
Powered by Kunena Forum