Dimensions in the page of a product

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Viewing 4 reply threads
  • Author
    Posts
    • #123442

      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.

    • #123583
      Sushobhan
      Keymaster

      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!

    • #123953

      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.
    • #124277
      Sushobhan
      Keymaster

      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.

    • #124449

      Hi,

      Review of the plugin done !
      Thanks again a lot !
      Aurélien

Viewing 4 reply threads
  • You must be logged in to reply to this topic.