You are here

protected function DryIcePlugin::getType in Commerce FedEx 8

Determine if this is a domestic or international shipment.

Parameters

\Drupal\commerce_shipping\Entity\ShipmentInterface $shipment: The shipment to check.

Return value

string either 'domestic' or 'intl'

2 calls to DryIcePlugin::getType()
DryIcePlugin::adjustPackage in modules/dry_ice/src/Plugin/Commerce/FedEx/DryIcePlugin.php
Adjust a package based on the items, shipment and profile.
DryIcePlugin::splitPackage in modules/dry_ice/src/Plugin/Commerce/FedEx/DryIcePlugin.php
Function splitPackage.

File

modules/dry_ice/src/Plugin/Commerce/FedEx/DryIcePlugin.php, line 294

Class

DryIcePlugin
Provides the Fedex Dry Ice Service.

Namespace

Drupal\commerce_fedex_dry_ice\Plugin\Commerce\FedEx

Code

protected function getType(ShipmentInterface $shipment) {

  /* @var  AddressItem $shipping_address */
  $shipping_address = $shipment
    ->getShippingProfile()
    ->get('address')
    ->first();
  $domestic = $shipping_address instanceof AddressItem ? $shipment
    ->getOrder()
    ->getStore()
    ->getAddress()
    ->getCountryCode() == $shipping_address
    ->getCountryCode() : FALSE;
  return $domestic ? 'domestic' : 'intl';
}