abstract class UPSEntity in Commerce UPS 8.3
Constructs a UPS Entity.
@package Drupal\commerce_ups
Hierarchy
- class \Drupal\commerce_ups\UPSEntity
Expanded class hierarchy of UPSEntity
File
- src/
UPSEntity.php, line 12
Namespace
Drupal\commerce_upsView source
abstract class UPSEntity {
/**
* Sets the unit of measurement for a UPS Entity.
*
* @param string $code
* The unit of measurement string.
*
* @return \Ups\Entity\UnitOfMeasurement
* The unit or measurement object for an API request.
*/
public function setUnitOfMeasurement($code) {
$ups_unit = new UnitOfMeasurement();
$ups_unit
->setCode($code);
return $ups_unit;
}
/**
* Convert commerce UOM to UPS API UOM.
*
* @param string $unit
* The string value provided by the Physical module.
*
* @return string
* The string value expected by UPS API.
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
UPSEntity:: |
public | function | Convert commerce UOM to UPS API UOM. | |
UPSEntity:: |
public | function | Sets the unit of measurement for a UPS Entity. |