Loading commerce_printful.services.yml +1 −1 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ services: # Order integrator service. commerce_printful.order_integrator: class: Drupal\commerce_printful\Service\OrderIntegrator arguments: ['@commerce_printful.printful', '@logger.factory'] arguments: ['@commerce_printful.printful', '@logger.factory', '@commerce_currency_resolver.calculator'] commerce_printful.order_subscriber: class: Drupal\commerce_printful\EventSubscriber\OrderEventSubscriber Loading src/OrderItemsTrait.php +1 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ trait OrderItemsTrait { $totalPrice = $orderItem->getTotalPrice(); // Convert currency to Printful default if required. if ($totalPrice->getCurrencyCode() !== $pf_currency) { if (isset($pf_currency) && $totalPrice->getCurrencyCode() !== $pf_currency) { $totalPrice = $this->priceExchangerCalculator->priceConversion($totalPrice, $pf_currency); } $item['name'] = $orderItem->label(); Loading src/Service/OrderIntegrator.php +15 −3 Original line number Diff line number Diff line Loading @@ -2,12 +2,13 @@ namespace Drupal\commerce_printful\Service; use Drupal\commerce_printful\OrderItemsTrait; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\commerce_printful\Entity\PrintfulStoreInterface; use Drupal\commerce_currency_resolver\PriceExchangerCalculator; use Drupal\commerce_order\Entity\OrderInterface; use Drupal\commerce_printful\Entity\PrintfulStoreInterface; use Drupal\commerce_printful\Exception\PrintfulException; use Drupal\commerce_printful\OrderItemsTrait; /** * Printful order integration service implementation. Loading Loading @@ -38,6 +39,13 @@ class OrderIntegrator implements OrderIntegratorInterface { */ protected $logger; /** * The Price Exchanger Calculator. * * @var \Drupal\commerce_currency_resolver\PriceExchangerCalculator */ protected $priceExchangerCalculator; /** * Constructor. * Loading @@ -45,13 +53,17 @@ class OrderIntegrator implements OrderIntegratorInterface { * The printful API service. * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory * The logger factory. * @param \Drupal\commerce_currency_resolver\PriceExchangerCalculator $price_exchanger_calculator * The Price exchange calculator service. */ public function __construct( Printful $pf, LoggerChannelFactoryInterface $logger_factory LoggerChannelFactoryInterface $logger_factory, PriceExchangerCalculator $price_exchanger_calculator ) { $this->pf = $pf; $this->logger = $logger_factory->get('commerce_printful'); $this->priceExchangerCalculator = $price_exchanger_calculator; } /** Loading Loading
commerce_printful.services.yml +1 −1 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ services: # Order integrator service. commerce_printful.order_integrator: class: Drupal\commerce_printful\Service\OrderIntegrator arguments: ['@commerce_printful.printful', '@logger.factory'] arguments: ['@commerce_printful.printful', '@logger.factory', '@commerce_currency_resolver.calculator'] commerce_printful.order_subscriber: class: Drupal\commerce_printful\EventSubscriber\OrderEventSubscriber Loading
src/OrderItemsTrait.php +1 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ trait OrderItemsTrait { $totalPrice = $orderItem->getTotalPrice(); // Convert currency to Printful default if required. if ($totalPrice->getCurrencyCode() !== $pf_currency) { if (isset($pf_currency) && $totalPrice->getCurrencyCode() !== $pf_currency) { $totalPrice = $this->priceExchangerCalculator->priceConversion($totalPrice, $pf_currency); } $item['name'] = $orderItem->label(); Loading
src/Service/OrderIntegrator.php +15 −3 Original line number Diff line number Diff line Loading @@ -2,12 +2,13 @@ namespace Drupal\commerce_printful\Service; use Drupal\commerce_printful\OrderItemsTrait; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\commerce_printful\Entity\PrintfulStoreInterface; use Drupal\commerce_currency_resolver\PriceExchangerCalculator; use Drupal\commerce_order\Entity\OrderInterface; use Drupal\commerce_printful\Entity\PrintfulStoreInterface; use Drupal\commerce_printful\Exception\PrintfulException; use Drupal\commerce_printful\OrderItemsTrait; /** * Printful order integration service implementation. Loading Loading @@ -38,6 +39,13 @@ class OrderIntegrator implements OrderIntegratorInterface { */ protected $logger; /** * The Price Exchanger Calculator. * * @var \Drupal\commerce_currency_resolver\PriceExchangerCalculator */ protected $priceExchangerCalculator; /** * Constructor. * Loading @@ -45,13 +53,17 @@ class OrderIntegrator implements OrderIntegratorInterface { * The printful API service. * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory * The logger factory. * @param \Drupal\commerce_currency_resolver\PriceExchangerCalculator $price_exchanger_calculator * The Price exchange calculator service. */ public function __construct( Printful $pf, LoggerChannelFactoryInterface $logger_factory LoggerChannelFactoryInterface $logger_factory, PriceExchangerCalculator $price_exchanger_calculator ) { $this->pf = $pf; $this->logger = $logger_factory->get('commerce_printful'); $this->priceExchangerCalculator = $price_exchanger_calculator; } /** Loading