Home › Forums › WoodMart support forum › Label on product doesn’t work
Label on product doesn’t work
- This topic has 8 replies, 2 voices, and was last updated 2 years, 1 month ago by Elise Noromit.
-
AuthorPosts
-
October 14, 2022 at 6:39 pm #413863
GiovanniParticipantHi,
the label on product image doesn’t work as you see into the attached image…so i’ve read the code into the file
wp-content/themes/woodmart/inc/integrations/woocommerce/template-tags.phpand after a var_dump on the line 1327 of the $output variable… there aren’t the label (you can see the output into the attachment file)
How can i solve?
thank you in advance
GiovanniAttachments:
You must be logged in to view attached files.October 15, 2022 at 12:55 am #413918
GiovanniParticipantok i found the bug…se here:
/** * ------------------------------------------------------------------------------------------------ * Attribute on product element * ------------------------------------------------------------------------------------------------ */ if ( ! function_exists( 'woodmart_get_product_attributes_label' ) ) { function woodmart_get_product_attributes_label() { global $product; $attributes = $product->get_attributes(); $output = array(); foreach ( $attributes as $attribute ) { if ( ! isset( $attribute['name'] ) ) { continue; } $show_attr_on_product = woodmart_wc_get_attribute_term( $attribute['name'], 'show_on_product' ); if ( $show_attr_on_product == 'on' ) { $terms = wc_get_product_terms( $product->get_id(), $attribute['name'], array( 'fields' => 'all' ) ); foreach ( $terms as $term ) { $content = esc_attr( $term->name ); $classes = 'label-term-' . $term->slug; $classes .= ' label-attribute-' . $attribute['name']; $image = get_term_meta( $term->term_id, 'image', true ); if ( $image ) { $classes .= ' label-with-img'; if ( is_array( $image ) && isset( $image['id'] ) ) { $content = wp_get_attachment_image( $image['id'], 'full', false, array( 'title' => $term->slug ) ); } else { $content = '<img src="' . esc_url( $image ) . '" title="' . esc_attr( $term->slug ) . '" alt="' . esc_attr( $term->slug ) . '" />'; } } $output[] = '<span class="attribute-label product-label ' . esc_attr( $classes ) . '">' . $content . '</span>'; } } } return $output; } }
the problem i suppose is that $image always return something so is always true and so i solved using
if ( strlen($image['url'])>0 ) {
i hope that this is useful for you 🙂
October 16, 2022 at 4:29 am #414103
Elise NoromitMemberHello,
Please remove all the custom codes and insert the site admin access into the Private content below the message area. We will take a closer look at the case.
Please, confirm the permission for plugin deactivation, and switching to the parent theme. As soon as we complete the testing we will enable all back, however, the site would be without plugins for 15-20 min. You would better make the full backup of your site.
Best Regards
October 17, 2022 at 12:57 pm #414360
GiovanniParticipantuhm i can create a backup that you can use locally to test what do you want but don’t change anything on site.
If you agree i’ll insert login data so you can download all
October 18, 2022 at 1:26 am #414528
Elise NoromitMemberHello,
Sure, please provide the access to the staging site.
Best Regards
October 19, 2022 at 5:14 pm #415050
GiovanniParticipantIf you want, here: https://www.missbaby.it/wp-admin/admin.php?page=ai1wm_backups
there is a backup copy done with All In One WP Migration, that you can install locally to test the issue.
Don’t edit anything on the production site pls 🙂thank you in advance
GiovanniOctober 20, 2022 at 4:43 am #415138
Elise NoromitMemberHello,
Please enable showing labels in the attribute: https://gyazo.com/c51da0711d823f094480c7d49709145f
You need to apply patch 414641: https://gyazo.com/da0437ac8d126e751537b0d1b484fad5
If you have any questions please feel free to contact us.
Best Regards
October 20, 2022 at 11:07 am #415225
GiovanniParticipantshowing labels in the attributes i want to show is yet enabled (for example: Anni, Brand etc)
but seems that the patch works 🙂
- This reply was modified 2 years, 1 month ago by Giovanni.
October 21, 2022 at 1:38 am #415429
Elise NoromitMemberHello,
We are glad the issue has been solved.
If you have any questions please feel free to contact us.
Best Regards
-
AuthorPosts
Tagged: Label
The topic ‘Label on product doesn’t work’ is closed to new replies.
- You must be logged in to create new topics. Login / Register