Compare shows attributes which should not be visible
-
Hi,
I’m currently using the plugin to compare several products with many attributes set. I have several attributes that are make as no visible (ie: Not ticked: “Visible on the product page”), however when compared these hidden attributes are displayed.
For the moment I’ve modified the local copy of the plugin to get round this but I wondered if you could add the following alteration to your next release, I’ve changed the following in shortcode.php (lines 152 to 165 (approx)):
foreach ( $product->get_attributes() as $attribute_id => $attribute ) { if ( $empty_selected || in_array( substr( $attribute['name'], 3 ), $selected_attributes ) ) { if ( !isset( $attributes[$attribute_id] ) ) { $attributes[$attribute_id] = array( 'name' => $attribute['name'], 'products' => array(), ); } $attributes[$attribute_id]['products'][$product->id] = $attribute['is_taxonomy'] ? wc_get_product_terms( $product->id, $attribute['name'], array( 'fields' => 'names' ) ) : array_map( 'trim', explode( WC_DELIMITER, $attribute['value'] ) ); } }
to:
foreach ( $product->get_attributes() as $attribute_id => $attribute ) { if ($attribute['is_visible']) { if ( $empty_selected || in_array( substr( $attribute['name'], 3 ), $selected_attributes ) ) { if ( !isset( $attributes[$attribute_id] ) ) { $attributes[$attribute_id] = array( 'name' => $attribute['name'], 'products' => array(), ); } $attributes[$attribute_id]['products'][$product->id] = $attribute['is_taxonomy'] ? wc_get_product_terms( $product->id, $attribute['name'], array( 'fields' => 'names' ) ) : array_map( 'trim', explode( WC_DELIMITER, $attribute['value'] ) ); } } }
That removed the hidden attributes that I don’t want to display.
Other than that, the plugin works great!
Best Regards
Tomhttps://www.ads-software.com/plugins/woocommerce-compare-list/
- The topic ‘Compare shows attributes which should not be visible’ is closed to new replies.