ResolvedAdd product weight below brief description

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #30726
    Guilherme Souza
    Participant

    Hello everyone, good afternoon.
    can you help me?

    I am trying to add the product weight below the short description.

    However, it is not working.

    Look: https://prnt.sc/15mk1e1

    Abóbora Cabotiá assada

    I added this item along with the brief description manually.
    https://prnt.sc/15mk2r5

    I would like it to be automatic.

    For that I created this snippet:

    add_filter('woocommerce_short_description','ts_add_text_short_descr');
    function ts_add_text_short_descr($description){
        global $product;  
    	$weight_unit = get_option('woocommerce_weight_unit');
    	$attributes = $product->get_attributes();
    	if ( $product->has_weight() ) {
    		$text= '<span class="barbasWeight">Peso: <span class="barbasWeight-values"> '.$product->get_weight(). $weight_unit . '</span></span>';
    		return $description.$text;
    	}
    }

    It worked well, however, it doesn’t work on variable products.

    Can you tell me how I can do this?

    Thank you very much

    #30736
    Althemist
    Keymaster

    Hi Guilherme Souza,

    In Lafka theme we have custom “serving size” field for teh weight. The product weight should be displayed automatically in the product short description between the text and the nutrition info. However, it looks like there were some changes in the latest WooCommerce which affect product data container classes, so it’s now hidden. We will release a fix next days.

    Meanwhile, until the update is released, you can use the following CSS to make it visible again:

    .summary .lafka-item-weight-holder {
        display: block !important;
    }

    Hope this helps.

    Regards,
    Dimitar

    #30750
    Guilherme Souza
    Participant

    Hello Dimitar, good afternoon.

    Thank you very much.

    It worked very well.
    This is exactly what I needed.

    I noticed only two small problems and I would like to know if they can be evaluated.

    This is a variable product we used from the demo: https://nutre.barbas.digital/produto/light-denim-dress/

    As you can see, the “serving size” is being displayed in two places: https://prnt.sc/15pruh0

    And the second problem is that it’s showing all the variations.

    Imagine a product with 50 variations.
    It will be huge.

    Would it be possible to display the “serving size” only of the selected variation?

    Thank you very much

    #30762
    Althemist
    Keymaster

    I am afraid no. You can’t list the serving size for each individual variation.

    Anyways, you can replace the code I gave you with the following CSS in order to only show it in one place:

    .summary .lafka-item-weight-holder {
        display: block !important;
    }
    .product-type-variable .summary .woocommerce-product-details__short-description .lafka-item-weight-holder {
        display: none !important;
    }
    .product-type-variable .summary .woocommerce-variation-description .lafka-item-weight-holder {
        display: block !important;
    }
    #30768
    Guilherme Souza
    Participant

    Hello Friend

    I understand.

    What a pity.
    I’ll think of something to help us with this,
    But thank you so much.

    With this CSS you uploaded, I was able to limit the display.
    This has helped a lot,

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

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register