![]() 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/Model/Express/Checkout/ |
<?php /** * Copyright © eComBricks. All rights reserved. * See LICENSE.txt for license details. */ namespace Ecombricks\InventoryPaypal\Model\Express\Checkout; /** * Paypal express checkout model source trait */ trait SourceTrait { /** * Orders * * @var array */ protected $orders; /** * Prepare shipping options * * @param \Magento\Quote\Model\Quote\Address $address * @param bool $mayReturnEmpty * @param bool $calculateTax * @return array|false */ protected function _prepareShippingOptions(\Magento\Quote\Model\Quote\Address $address, $mayReturnEmpty = false, $calculateTax = false) { return []; } /** * Ignore address validation * * @return $this */ protected function ignoreAddressValidation() { $billingAddress = $this->_quote->getBillingAddress(); $billingAddress->setShouldIgnoreValidation(true); if ($this->_quote->getIsVirtual()) { return $this; } $shippingAddress = $this->_quote->getShippingAddress(); $shippingAddress->setShouldIgnoreValidation(true); if (!$this->_config->getValue('requireBillingAddress') && !$billingAddress->getEmail()) { $billingAddress->setSameAsBilling(1); } return $this; } /** * Send order email * * @param \Magento\Sales\Api\Data\OrderInterface $order * @return $this */ protected function sendOrderEmail(\Magento\Sales\Api\Data\OrderInterface $order) { if (!in_array($order->getState(), [ \Magento\Sales\Model\Order::STATE_PROCESSING, \Magento\Sales\Model\Order::STATE_COMPLETE, \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW, ])) { return $this; } if ($order->getEmailSent()) { return $this; } try { $this->orderSender->send($order); } catch (\Exception $exception) { $this->_logger->critical($exception); } $this->_checkoutSession->start(); return $this; } /** * Get orders * * @return array */ public function getOrders() { return $this->_orders; } /** * Place * * @param string $token * @param string|null $shippingMethodCode * @return $this */ public function inventoryPlace($token, $shippingMethodCode = null) { if ($shippingMethodCode) { $this->updateShippingMethod($shippingMethodCode); } if ($this->getCheckoutMethod() == \Magento\Checkout\Model\Type\Onepage::METHOD_GUEST) { $this->prepareGuestQuote(); } $this->ignoreAddressValidation(); $this->_quote->collectTotals(); $orders = $this->quoteManagement->submit($this->_quote); if (empty($orders)) { return $this; } $order = current($orders); if ($order->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_REDIRECT)) { $this->_redirectUrl = $this->_config->getExpressCheckoutCompleteUrl($token); } foreach ($orders as $order) { $this->sendOrderEmail($order); } $this->_orders = $orders; return $this; } }