class ShippingCurrencyOrderProcessor in Commerce Currency Resolver 8
Force refresh of shipping rates for shipment for currency changes.
Hierarchy
- class \Drupal\commerce_currency_resolver_shipping\ShippingCurrencyOrderProcessor implements OrderProcessorInterface
Expanded class hierarchy of ShippingCurrencyOrderProcessor
1 string reference to 'ShippingCurrencyOrderProcessor'
- commerce_currency_resolver_shipping.services.yml in modules/
shipping/ commerce_currency_resolver_shipping.services.yml - modules/shipping/commerce_currency_resolver_shipping.services.yml
1 service uses ShippingCurrencyOrderProcessor
File
- modules/
shipping/ src/ ShippingCurrencyOrderProcessor.php, line 13
Namespace
Drupal\commerce_currency_resolver_shippingView source
class ShippingCurrencyOrderProcessor implements OrderProcessorInterface {
/**
* The shipping order manager.
*
* @var \Drupal\commerce_shipping\ShippingOrderManagerInterface
*/
protected $shippingOrderManager;
/**
* Constructs a new ShippingCurrencyOrderProcessor object.
*
* @param \Drupal\commerce_shipping\ShippingOrderManagerInterface $shipping_order_manager
* The shipping order manager.
*/
public function __construct(ShippingOrderManagerInterface $shipping_order_manager) {
$this->shippingOrderManager = $shipping_order_manager;
}
/**
* {@inheritdoc}
*/
public function process(OrderInterface $order) {
// No shipment, skip order.
if (!$this->shippingOrderManager
->hasShipments($order)) {
return;
}
// No need to trigger this processor.
if (!$order
->getData(CurrencyHelper::CURRENCY_ORDER_REFRESH)) {
return;
}
// Unset flag.
$order
->unsetData(CurrencyHelper::CURRENCY_ORDER_REFRESH);
// If we don't have already this flag, trigger it.
// Otherwise amount on shipment is gonna be on old currency.
if (!$order
->getData(ShippingOrderManagerInterface::FORCE_REFRESH)) {
$order
->setData(ShippingOrderManagerInterface::FORCE_REFRESH, TRUE);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ShippingCurrencyOrderProcessor:: |
protected | property | The shipping order manager. | |
ShippingCurrencyOrderProcessor:: |
public | function |
Processes an order. Overrides OrderProcessorInterface:: |
|
ShippingCurrencyOrderProcessor:: |
public | function | Constructs a new ShippingCurrencyOrderProcessor object. |