Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › Dimensions in the page of a product
- This topic has 4 replies, 2 voices, and was last updated 4 years, 6 months ago by aurelien_boutillier.
- AuthorPosts
- April 27, 2020 at 2:47 am #123442aurelien_boutillierParticipant
Hello,
I would like to dispaly the dimensions in the page of a product
I would like to display the dimensions of a product in this form specifying Height, Lenght, width, for example :
H. 38 cm X L. 55 cm
Today I have the following form: 55 x 38 cm.
Ideally, if it’s possible I would prefer display first the height, then the Lenght, then the width.Thanks for you help
Have a good day
Aurélien. - April 27, 2020 at 12:48 pm #123583SushobhanKeymaster
Hi,
Thanks for getting in touch with us!
This is not related to WCFM and fully controlled by WooCommerce. Though I have write a snippet for you which can help you achieving your purpose –add_filter('woocommerce_display_product_attributes', function( $product_attributes, $product ) { if(isset($product_attributes['dimensions'])) { $dimension = $product->get_dimensions( false ); $formatted_dimension = array(); if(!empty($dimension['height']))$formatted_dimension['height'] = "H. " . format_dimension_item($dimension['height']); if(!empty($dimension['length']))$formatted_dimension['length'] = "L. " . format_dimension_item($dimension['length']); if(!empty($dimension['width']))$formatted_dimension['width'] = "W. " . format_dimension_item($dimension['width']); $product_attributes['dimensions']['value'] = implode( ' × ', array_filter($formatted_dimension) ); } return $product_attributes; }, 10, 2); function format_dimension_item($d) { return wc_format_localized_decimal($d) . " " . get_option( 'woocommerce_dimension_unit' ); }
Add this code to your child theme’s functions.php
In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/
Let me know how it goes.
Thanks! - April 28, 2020 at 3:17 am #123953aurelien_boutillierParticipant
Hi Sushobhan,
It works perfectly ! Thank you very much.
FInd attached the screenshot.
I have just changed abbreviation H/L/W by H/L/l to be in french.Thanks a lot.
Have a good day
Aurélien.Attachments:
You must be logged in to view attached files. - April 28, 2020 at 7:03 pm #124277SushobhanKeymaster
That’s great 🙂
Let me know if there’s anything else we can help you with.
Can we ask for a favor? Would you mind taking a few minutes to review our plugin (if you haven’t already) at https://wordpress.org/support/plugin/wc-multivendor-marketplace/reviews/ and let others know about your 5 Star experience with WCFM Marketplace. Also, follow us on Twitter https://twitter.com/wcfmmp for more exciting news, important updates, and irresistible offers. - April 29, 2020 at 3:22 am #124449aurelien_boutillierParticipant
Hi,
Review of the plugin done !
Thanks again a lot !
Aurélien
- AuthorPosts
- You must be logged in to reply to this topic.