Home Forums WoodMart support forum Adding icon to global attribute “Weight”

Adding icon to global attribute “Weight”

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #700506

    bv
    Participant

    Hello there,

    I want to add an SVG icon for “Weight” global attribute, as I have icons for all others attributes?
    How can I add icon for global attribute “Weight”?

    Regards,

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

    Hello,

    I have checked the Weight global attribute on your site, and the SVG icon is displaying correctly now. It seems the issue has already been resolved on your side. If you still need help adding or replacing the icon, feel free to let me know.

    See screenshot for clarification: https://postimg.cc/QKZhY07g

    Best Regards,

    #700675

    bv
    Participant

    Hello,

    Yes – I have found the solution by adding this piece of code inside functions.php file of a child theme.

    // ikonica za weight atribut
    add_filter( 'woocommerce_display_product_attributes', 'mp_add_weight_icon_attribute' );
    function mp_add_weight_icon_attribute( $attributes ) {
    
        // Ako postoji weight atribut, dodamo HTML ikonicu
        if ( isset( $attributes['weight'] ) ) {
    
            $icon_url = '/wp-content/uploads/2025/12/tezina.svg';
    
            // Upisujemo custom HTML u label
            $attributes['weight']['label'] = '
                <span class="wd-attr-name">
                    <img 
                        src="/wp-content/themes/woodmart/images/lazy.svg"
                        data-src="' . esc_url( $icon_url ) . '" 
                        class="wd-lazy-fade wd-attr-name-img"
                        width="150" height="150"
                        alt="Težina"
                        loading="lazy"
                    />
                    <span class="wd-attr-name-label">Težina</span>
                    <span class="wd-hint wd-tooltip">Ukupna težina proizvoda</span>
                </span>
            ';
        }
    
        return $attributes;
    }

    Is there any better or easier solution from your side?

    Regards

    #700706

    Hello,

    Yes, your method works fine, and it’s safe to use since you added it inside the child theme. At the moment, WoodMart does not provide a built-in option to upload a custom SVG icon for individual global attributes.

    Best Regards,

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