ResolvedAdd product weight below brief description
- This topic has 4 replies, 2 voices, and was last updated 2 years, 3 months ago by
Guilherme Souza.
- AuthorPosts
- June 16, 2021 at 9:12 pm #30726
Guilherme Souza
ParticipantHello 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
I added this item along with the brief description manually.
https://prnt.sc/15mk2r5I 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
June 17, 2021 at 5:25 pm #30736Althemist
KeymasterHi 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,
DimitarJune 17, 2021 at 6:14 pm #30750Guilherme Souza
ParticipantHello 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
June 18, 2021 at 4:56 pm #30762Althemist
KeymasterI 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; }
June 18, 2021 at 6:35 pm #30768Guilherme Souza
ParticipantHello 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, - AuthorPosts
You must be logged in and have valid license to reply to this topic.