You are here

public function UPSEntity::getUnitOfMeasure in Commerce UPS 8.3

Convert commerce UOM to UPS API UOM.

Parameters

string $unit: The string value provided by the Physical module.

Return value

string The string value expected by UPS API.

2 calls to UPSEntity::getUnitOfMeasure()
UPSShipment::setDimensions in src/UPSShipment.php
Package dimension setter.
UPSShipment::setWeight in src/UPSShipment.php
Define the package weight.

File

src/UPSEntity.php, line 39

Class

UPSEntity
Constructs a UPS Entity.

Namespace

Drupal\commerce_ups

Code

public function getUnitOfMeasure($unit) {
  switch ($unit) {
    case 'lb':
      return UnitOfMeasurement::PROD_POUNDS;
    case 'kg':
      return UnitOfMeasurement::PROD_KILOGRAMS;
    case 'in':
      return UnitOfMeasurement::UOM_IN;
    case 'cm':
      return UnitOfMeasurement::UOM_CM;
  }
  return $unit;
}