Your cart is currently empty!
Custom Per Product Units for WooCommerce is a versatile plugin that lets you display product dimensions and weight in custom units on a per-product basis. This tool allows you to meet regional measurement standards and enhance the customer experience. Moreover, it easily overrides WooCommerce’s default settings. In short, our plugin ensures every product listing meets your specific market needs and improves conversion rates.
Follow these steps to configure custom units for a WooCommerce product:
Once you configure the custom units, they display on the Single Product Page. In the Additional Information tab, the product’s weight and dimensions show up using your selected units and conversions.
Developers can modify the plugin using various filters:
cumfw_weight_units
– Change the available weight units.cumfw_convert_weight
– Adjust the weight conversion logic.cumfw_weight_decimals
– Set the decimal precision for weight values.cumfw_dimension_units
– Modify the list of available dimension units.cumfw_convert_dimension
– Customize the dimension conversion logic.
Developers can extend this plugin by adding custom filters. For example, you can add new weight or dimension units, modify conversion rules, or adjust decimal precision.
For instance, to add ounces (oz) as a weight unit, use the filter below. First, add your custom unit, then adjust conversion rates accordingly.
<?php add_filter( 'cumfw_weight_units', function( $units ) { $units['ounce'] = __( 'Ounces (oz)', 'custom-unit-manager-for-woocommerce' ); return $units; }); // Define conversion logic for "ounce". add_filter( 'cumfw_convert_weight', function( $weight, $weight_in_kg, $custom_weight_unit ) { if ( 'ounce' === $custom_weight_unit ) { // 1 kilogram = 35.274 ounces. return $weight_in_kg * 35.274; } return null; }, 10, 3 );
Alternatively, remove decimals for grams by modifying the precision filter:
<?php add_filter( 'cumfw_weight_decimals', function( $decimals, $unit ) { if ( 'g' === $unit ) { return 0; } return $decimals; }, 10, 2 );
Finally, to introduce a new dimension unit like yards (yd), implement this filter:
<?php add_filter( 'cumfw_dimension_units', function( $units ) { $units['yard'] = __( 'Yards (yd)', 'custom-unit-manager-for-woocommerce' ); return $units; }); // Define conversion logic for "yard". add_filter( 'cumfw_convert_dimension', function( $dimension, $dimension_in_meters, $custom_dimension_unit ) { if ( 'yard' === $custom_dimension_unit ) { // 1 meter = 1.09361 yards. return $dimension_in_meters * 1.09361; } return null; }, 10, 3 );
You can insert these code snippets into your theme’s functions.php
file or manage them with a plugin such as Code Snippets for better control.
If you have any questions or need further assistance with woocommerce custom per product units, please Contact our Support. You may also visit the WooCommerce official website for additional resources.