Spamworldpro Mini Shell
Spamworldpro


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/InventoryCheckout/Plugin/Model/Type/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/Ecombricks/InventoryCheckout/Plugin/Model/Type/Onepage.php
<?php
/**
 * Copyright © eComBricks. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Ecombricks\InventoryCheckout\Plugin\Model\Type;

/**
 * Onepage checkout plugin
 */
class Onepage
{
    
    /**
     * Joint data
     * 
     * @var \Ecombricks\InventoryQuote\Data\JointData
     */
    protected $jointData;
    
    /**
     * Quote config
     * 
     * @var \Ecombricks\InventoryQuote\Model\Config
     */
    protected $quoteConfig;
    
    /**
     * Constructor
     * 
     * @param \Ecombricks\InventoryQuote\Data\JointData $jointData
     * @param \Ecombricks\InventoryQuote\Model\Config $quoteConfig
     * @return void
     */
    public function __construct(
        \Ecombricks\InventoryQuote\Data\JointData $jointData,
        \Ecombricks\InventoryQuote\Model\Config $quoteConfig
    )
    {
        $this->jointData = $jointData;
        $this->quoteConfig = $quoteConfig;
    }
    
    /**
     * Save shipping method
     *
     * @param string|array $shippingMethod
     * @return array
     */
    public function saveShippingMethod($shippingMethod)
    {
        $invalidResult = ['error' => -1, 'message' => __('Invalid shipping methods')];
        if (empty($shippingMethod)) {
            return $invalidResult;
        }
        if (!is_array($shippingMethod)) {
            $shippingMethods = $this->jointData->parse($shippingMethod);
        } else {
            $shippingMethods = $shippingMethod;
        }
        if (empty($shippingMethods)) {
            return $invalidResult;
        }
        $quote = $this->getQuote();
        $shippingAddress = $quote->getShippingAddress();
        $shippingAddress->setShippingMethod($shippingMethods);
        $shippingAddress->generateShippingDescription();
        $shippingAddress->save();
        $this
            ->getCheckout()
            ->setStepData('shipping_method', 'complete', true)
            ->setStepData('payment', 'allow', true);
        return [];
    }
    
    /**
     * Around save shipping method
     * 
     * @param \Magento\Checkout\Model\Type\Onepage $subject
     * @param \Closure $proceed
     * @param string|array $shippingMethod
     * @return array
     */
    public function aroundSaveShippingMethod(
        \Magento\Checkout\Model\Type\Onepage $subject,
        \Closure $proceed,
        $shippingMethod
    )
    {
        return $this->saveShippingMethod($shippingMethod);
    }
    
    /**
     * Around save order
     * 
     * @param \Magento\Checkout\Model\Type\Onepage $subject
     * @param \Closure $proceed
     * @return \Magento\Checkout\Model\Type\Onepage
     */
    public function aroundSaveOrder(
        \Magento\Checkout\Model\Type\Onepage $subject,
        \Closure $proceed
    )
    {
        if (!$this->quoteConfig->isSplitOrder()) {
            return $proceed();
        }
        return $subject->inventorySaveOrder();
    }
    
}

Spamworldpro Mini