This module provides a system for storing and converting physical measurements like length, weight, and temperature. It includes field types for single measurements and dimensions, with support for language-specific formatting and precise arithmetic.
This module provides an API for storing and manipulating physical measurements. It also supports unit conversions.
Features
Supported measurement types:
- Area
- Length
- Temperature
- Volume
- Weight
Provided field types:
- Physical measurement: Stores a single measurement and its unit.
- Physical dimensions: Stores the length/width/height measurements and their unit.
Other features:
- Language-specific number input and formatting
- Value objects with support for bcmath-based arithmetic.
Drupal 9 & 10 & 11
Installation
Physical should only be installed via Composer. The zip files on this page are provided for informative purposes only.
Drupal 9 or newer is required.
Example:use Drupal\physical\Weight;
use Drupal\physical\WeightUnit;
$weight = new Weight('100', WeightUnit::KILOGRAM);
$other_weight = new Weight('120', WeightUnit::KILOGRAM);
// Add the two weights together then express them in pounds.
$new_weight = $weight->add($other_weight)->convert(WeightUnit::POUND);
Incompatibility notes
Physical 1.3+ is incompatible with Commerce versions prior to 2.34 (See https://www.drupal.org/project/physical/issues/3345698#comment-15019339).
Ask your assistant about Physical Fields
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
- field Drupal core
Required by
4 tracked projects depend on this one
- Commerce Shipping 15,226 sites
- Commerce Shipping Linear Weight 33 sites
- Commerce Shipping extra weight rate 29 sites
- Commerce Measurement Condition 9 sites