![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/Ecombricks/InventoryPaypal/Plugin/Helper/ |
<?php /** * Copyright © eComBricks. All rights reserved. * See COPYING.txt for license details. */ namespace Ecombricks\InventoryPaypal\Plugin\Helper; /** * Paypal checkout helper plugin */ class Checkout { /** * Session * * @var \Ecombricks\InventoryCheckout\Model\Session */ protected $session; /** * Quote config * * @var \Ecombricks\InventoryQuote\Model\Config */ protected $quoteConfig; /** * Constructor * * @param \Ecombricks\InventoryCheckout\Model\Session $session * @param \Ecombricks\InventoryQuote\Model\Config $quoteConfig * @return void */ public function __construct( \Ecombricks\InventoryCheckout\Model\Session $session, \Ecombricks\InventoryQuote\Model\Config $quoteConfig ) { $this->session = $session; $this->quoteConfig = $quoteConfig; } /** * Cancel current order * * @param string $comment * @return bool */ public function cancelCurrentOrder($comment) { $canceled = false; $orders = $this->session->getLastRealOrders(); if (empty($orders)) { return $canceled; } foreach ($orders as $order) { if (!$order->getId() || $order->getState() == \Magento\Sales\Model\Order::STATE_CANCELED) { continue; } $order->registerCancellation($comment)->save(); $canceled = true; } return $canceled; } /** * Around cancel current order * * @param \Magento\Paypal\Helper\Checkout $subject * @param callable $proceed * @param string $comment * @return bool */ public function aroundCancelCurrentOrder( \Magento\Paypal\Helper\Checkout $subject, \Closure $proceed, $comment ) { if (!$this->quoteConfig->isSplitOrder()) { return $proceed($comment); } return $this->cancelCurrentOrder($comment); } }