Hide field if no value
-
Hi
I have different machines and cleaning products in my woocommerce.
Now you can imagine that you cant compare a cleaning product with a high pressure machine.
However when i am comparing multiple cleaning products all fields are showing including the properties of the high pressure machine. So all these fields are empty and a waste of space.
How can i hide i field when no value is entered?
I found this but it does not work:
protected function _vars() {
$vars = array(
‘products’ => $this->get_products_list(),
‘fields’ => $this->fields(),
‘repeat_price’ => get_option( ‘yith_woocompare_price_end’ ),
‘repeat_add_to_cart’ => get_option( ‘yith_woocompare_add_to_cart_end’ ),
);// Hide empty fields
$fieldsExists = array();
foreach($vars[‘fields’] as $field => $title) {
foreach($vars[‘products’] as $product) {
if($product->fields[$field]) {
$fieldsExists[$field] = $title;
}
}
}
$vars[‘fields’] = $fieldsExists;return $vars;
}https://www.ads-software.com/plugins/yith-woocommerce-compare/
- The topic ‘Hide field if no value’ is closed to new replies.