Home Forums WoodMart support forum Label on product doesn’t work

Label on product doesn’t work

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #413863

    Giovanni
    Participant

    Hi,

    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.php

    and 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
    Giovanni

    Attachments:
    You must be logged in to view attached files.
    #413918

    Giovanni
    Participant

    ok 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 🙂

    #414103

    Hello,

    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

    #414360

    Giovanni
    Participant

    uhm 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

    #414528

    Hello,

    Sure, please provide the access to the staging site.

    Best Regards

    #415050

    Giovanni
    Participant

    If 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
    Giovanni

    #415138

    Hello,

    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

    #415225

    Giovanni
    Participant

    showing 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 ago by Giovanni.
    #415429

    Hello,

    We are glad the issue has been solved.

    If you have any questions please feel free to contact us.

    Best Regards

Tagged: 

Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘Label on product doesn’t work’ is closed to new replies.