Пример #1
0
 protected function setUp()
 {
     $this->carrier = $this->getMock('Magento\\Shipping\\Model\\Carrier\\AbstractCarrier', [], [], '', false);
     $this->carrier->expects($this->any())->method('getConfigData')->will($this->returnCallback(function ($key) {
         $configData = ['max_package_weight' => 10];
         return isset($configData[$key]) ? $configData[$key] : 0;
     }));
     $this->stockRegistry = $this->getMock('Magento\\CatalogInventory\\Model\\StockRegistry', [], [], '', false);
     $this->stockItemData = $this->getMock('Magento\\CatalogInventory\\Model\\Stock\\Item', [], [], '', false);
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->shipping = $objectManagerHelper->getObject('Magento\\Shipping\\Model\\Shipping', ['stockRegistry' => $this->stockRegistry]);
 }
 /**
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory
  * @param \Psr\Log\LoggerInterface $logger
  * @param \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory
  * @param \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory
  * @param ItemPriceCalculator $itemPriceCalculator
  * @param array $data
  */
 public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Psr\Log\LoggerInterface $logger, \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory, \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory, \Magento\OfflineShipping\Model\Carrier\Flatrate\ItemPriceCalculator $itemPriceCalculator, array $data = [])
 {
     $this->_rateResultFactory = $rateResultFactory;
     $this->_rateMethodFactory = $rateMethodFactory;
     $this->itemPriceCalculator = $itemPriceCalculator;
     parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data);
 }
Пример #3
0
 public function __construct(\Ess\M2ePro\Helper\Factory $helperFactory, \Magento\Quote\Model\Quote\Address\RateRequestFactory $rateRequestFactory, \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateResultMethodFactory, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Psr\Log\LoggerInterface $logger, \Magento\Shipping\Model\Rate\ResultFactory $resultFactory, array $data = [])
 {
     $this->helperFactory = $helperFactory;
     $this->resultFactory = $resultFactory;
     $this->rateRequestFactory = $rateRequestFactory;
     $this->rateResultMethodFactory = $rateResultMethodFactory;
     parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data);
 }
Пример #4
0
 /**
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeInterface
  * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory
  * @param \Psr\Log\LoggerInterface $logger
  * @param \Magento\Shipping\Model\Rate\ResultFactory $rateFactory
  * @param \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory
  * @param \Owebia\ShippingCore\Helper\Registry $registryHelper
  * @param \Owebia\ShippingCore\Helper\Config $configHelper
  * @param \Owebia\ShippingCore\Logger\Logger $debugLogger
  * @param array $data
  */
 public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeInterface, \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Psr\Log\LoggerInterface $logger, \Magento\Shipping\Model\Rate\ResultFactory $rateFactory, \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory, \Owebia\ShippingCore\Helper\Registry $registryHelper, \Owebia\ShippingCore\Helper\Config $configHelper, \Owebia\ShippingCore\Logger\Logger $debugLogger, array $data = [])
 {
     parent::__construct($scopeInterface, $rateErrorFactory, $logger, $data);
     $this->rateFactory = $rateFactory;
     $this->rateMethodFactory = $rateMethodFactory;
     $this->registryHelper = $registryHelper;
     $this->configHelper = $configHelper;
     $this->debugLogger = $debugLogger;
 }
Пример #5
0
 /**
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory
  * @param \Psr\Log\LoggerInterface $logger
  * @param \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory
  * @param \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $resultMethodFactory
  * @param \Magento\OfflineShipping\Model\ResourceModel\Carrier\TablerateFactory $tablerateFactory
  * @param array $data
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Psr\Log\LoggerInterface $logger, \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory, \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $resultMethodFactory, \Magento\OfflineShipping\Model\ResourceModel\Carrier\TablerateFactory $tablerateFactory, array $data = [])
 {
     $this->_rateResultFactory = $rateResultFactory;
     $this->_resultMethodFactory = $resultMethodFactory;
     $this->_tablerateFactory = $tablerateFactory;
     parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data);
     foreach ($this->getCode('condition_name') as $k => $v) {
         $this->_conditionNames[] = $k;
     }
 }
Пример #6
0
 /**
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory
  * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory
  * @param \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory
  * @param \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory
  * @param array $data
  */
 public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory, \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory, \Psr\Log\LoggerInterface $logger, array $data = array())
 {
     $this->_rateResultFactory = $rateResultFactory;
     $this->_rateMethodFactory = $rateMethodFactory;
     //        $config = array(
     //            'app_name'      => 'Default App Name', // Application Name
     //            'app_version'   => '0.0.1',            // Application Version
     //            'app_host'      => '', // Framework/CMS name and version, eg 'Wordpress 3.8.1 WooCommerce 2.0.20' / 'Joomla! 2.5.17 VirtueMart 2.0.26d'
     //            'app_url'       => '', // URL your site is hosted on
     //            'user_email'    => '*****@*****.**',
     //            'user_password' => 'api123',
     //            'demo'          => false,
     //        );
     //        parent::__construct($scopeConfig, $rateErrorFactory, $logAdapterFactory, $data);
     parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data);
     //        $collivery = new \MDS\Collivery\Model\Collivery($config);
     //
     //        $this->collivery = $collivery;
 }
 /**
  * @return bool
  */
 public function isActive()
 {
     if (!$this->_scopeConfig->isSetFlag('payment/mercadopago_standard/active')) {
         return false;
     }
     if (!$this->_helperCarrierData->isCountryEnabled()) {
         return false;
     }
     return parent::isActive();
 }
Пример #8
0
 /**
  * Compose Packages For Carrier.
  * Divides order into items and items into parts if it's necessary
  *
  * @param \Magento\Shipping\Model\Carrier\AbstractCarrier $carrier
  * @param \Magento\Sales\Model\Quote\Address\RateRequest $request
  * @return array [int, float]
  */
 public function composePackagesForCarrier($carrier, $request)
 {
     $allItems = $request->getAllItems();
     $fullItems = array();
     $maxWeight = (double) $carrier->getConfigData('max_package_weight');
     /** @var $item \Magento\Sales\Model\Quote\Item */
     foreach ($allItems as $item) {
         if ($item->getProductType() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE && $item->getProduct()->getShipmentType()) {
             continue;
         }
         $qty = $item->getQty();
         $changeQty = true;
         $checkWeight = true;
         $decimalItems = array();
         if ($item->getParentItem()) {
             if (!$item->getParentItem()->getProduct()->getShipmentType()) {
                 continue;
             }
             $qty = $item->getIsQtyDecimal() ? $item->getParentItem()->getQty() : $item->getParentItem()->getQty() * $item->getQty();
         }
         $itemWeight = $item->getWeight();
         if ($item->getIsQtyDecimal() && $item->getProductType() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
             $productId = $item->getProduct()->getId();
             if ($this->stockItemService->getStockItem($productId)->getIsDecimalDivided()) {
                 if ($this->stockItemService->getEnableQtyIncrements($productId) && $this->stockItemService->getQtyIncrements($productId)) {
                     $itemWeight = $itemWeight * $this->stockItemService->getQtyIncrements($productId);
                     $qty = round($item->getWeight() / $itemWeight * $qty);
                     $changeQty = false;
                 } else {
                     $itemWeight = $itemWeight * $item->getQty();
                     if ($itemWeight > $maxWeight) {
                         $qtyItem = floor($itemWeight / $maxWeight);
                         $decimalItems[] = array('weight' => $maxWeight, 'qty' => $qtyItem);
                         $weightItem = $this->mathDivision->getExactDivision($itemWeight, $maxWeight);
                         if ($weightItem) {
                             $decimalItems[] = array('weight' => $weightItem, 'qty' => 1);
                         }
                         $checkWeight = false;
                     } else {
                         $itemWeight = $itemWeight * $item->getQty();
                     }
                 }
             } else {
                 $itemWeight = $itemWeight * $item->getQty();
             }
         }
         if ($checkWeight && $maxWeight && $itemWeight > $maxWeight) {
             return array();
         }
         if ($changeQty && !$item->getParentItem() && $item->getIsQtyDecimal() && $item->getProductType() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
             $qty = 1;
         }
         if (!empty($decimalItems)) {
             foreach ($decimalItems as $decimalItem) {
                 $fullItems = array_merge($fullItems, array_fill(0, $decimalItem['qty'] * $qty, $decimalItem['weight']));
             }
         } else {
             $fullItems = array_merge($fullItems, array_fill(0, $qty, $itemWeight));
         }
     }
     sort($fullItems);
     return $this->_makePieces($fullItems, $maxWeight);
 }
Пример #9
0
 /**
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory
  * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory
  * @param \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory
  * @param \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory
  * @param array $data
  */
 public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory, \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory, array $data = array())
 {
     $this->_rateResultFactory = $rateResultFactory;
     $this->_rateMethodFactory = $rateMethodFactory;
     parent::__construct($scopeConfig, $rateErrorFactory, $logAdapterFactory, $data);
 }
Пример #10
0
 /**
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory
  * @param \Psr\Log\LoggerInterface $logger
  * @param Security $xmlSecurity
  * @param \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory
  * @param \Magento\Shipping\Model\Rate\ResultFactory $rateFactory
  * @param \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory
  * @param \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory
  * @param \Magento\Shipping\Model\Tracking\Result\ErrorFactory $trackErrorFactory
  * @param \Magento\Shipping\Model\Tracking\Result\StatusFactory $trackStatusFactory
  * @param \Magento\Directory\Model\RegionFactory $regionFactory
  * @param \Magento\Directory\Model\CountryFactory $countryFactory
  * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
  * @param \Magento\Directory\Helper\Data $directoryData
  * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry
  * @param array $data
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Psr\Log\LoggerInterface $logger, Security $xmlSecurity, \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory, \Magento\Shipping\Model\Rate\ResultFactory $rateFactory, \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory, \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory, \Magento\Shipping\Model\Tracking\Result\ErrorFactory $trackErrorFactory, \Magento\Shipping\Model\Tracking\Result\StatusFactory $trackStatusFactory, \Magento\Directory\Model\RegionFactory $regionFactory, \Magento\Directory\Model\CountryFactory $countryFactory, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Directory\Helper\Data $directoryData, \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, array $data = [])
 {
     $this->_xmlElFactory = $xmlElFactory;
     $this->_rateFactory = $rateFactory;
     $this->_rateMethodFactory = $rateMethodFactory;
     $this->_trackFactory = $trackFactory;
     $this->_trackErrorFactory = $trackErrorFactory;
     $this->_trackStatusFactory = $trackStatusFactory;
     $this->_regionFactory = $regionFactory;
     $this->_countryFactory = $countryFactory;
     $this->_currencyFactory = $currencyFactory;
     $this->_directoryData = $directoryData;
     $this->stockRegistry = $stockRegistry;
     parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data);
     $this->xmlSecurity = $xmlSecurity;
 }
 /**
  * @param ScopeConfigInterface $scopeConfig
  * @param ErrorFactory $rateErrorFactory
  * @param LoggerInterface $logger
  * @param ResultFactory $rateResultFactory
  * @param MethodFactory $rateMethodFactory
  * @param array $data
  */
 public function __construct(ScopeConfigInterface $scopeConfig, ErrorFactory $rateErrorFactory, LoggerInterface $logger, ResultFactory $rateResultFactory, MethodFactory $rateMethodFactory, array $data = [])
 {
     $this->_rateResultFactory = $rateResultFactory;
     $this->_rateMethodFactory = $rateMethodFactory;
     parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data);
 }
Пример #12
0
 /**
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory
  * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory
  * @param \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory
  * @param \Magento\Shipping\Model\Rate\ResultFactory $rateFactory
  * @param \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory
  * @param \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory
  * @param \Magento\Shipping\Model\Tracking\Result\ErrorFactory $trackErrorFactory
  * @param \Magento\Shipping\Model\Tracking\Result\StatusFactory $trackStatusFactory
  * @param \Magento\Directory\Model\RegionFactory $regionFactory
  * @param \Magento\Directory\Model\CountryFactory $countryFactory
  * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
  * @param \Magento\Directory\Helper\Data $directoryData
  * @param \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService
  * @param array $data
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory, \Magento\Shipping\Model\Rate\ResultFactory $rateFactory, \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory, \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory, \Magento\Shipping\Model\Tracking\Result\ErrorFactory $trackErrorFactory, \Magento\Shipping\Model\Tracking\Result\StatusFactory $trackStatusFactory, \Magento\Directory\Model\RegionFactory $regionFactory, \Magento\Directory\Model\CountryFactory $countryFactory, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Directory\Helper\Data $directoryData, \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService, array $data = array())
 {
     $this->_xmlElFactory = $xmlElFactory;
     $this->_rateFactory = $rateFactory;
     $this->_rateMethodFactory = $rateMethodFactory;
     $this->_trackFactory = $trackFactory;
     $this->_trackErrorFactory = $trackErrorFactory;
     $this->_trackStatusFactory = $trackStatusFactory;
     $this->_regionFactory = $regionFactory;
     $this->_countryFactory = $countryFactory;
     $this->_currencyFactory = $currencyFactory;
     $this->_directoryData = $directoryData;
     $this->stockItemService = $stockItemService;
     parent::__construct($scopeConfig, $rateErrorFactory, $logAdapterFactory, $data);
 }
Пример #13
0
 /**
  * @param \ShipperHQ\Shipper\Helper\Data $shipperDataHelper
  * @param \ShipperHQ\Shipper\Helper\Rest $restHelper
  * @param \ShipperHQ\Shipper\Helper\CarrierCache $carrierCache
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \ShipperHQ\Shipper\Helper\LogAssist $shipperLogger
  * @param \Psr\Log\LoggerInterface $logger
  * @param Config $configHelper
  * @param Processor\ShipperMapper $shipperMapper
  * @param Processor\CarrierConfigHandler $carrierConfigHandler
  * @param Processor\BackupCarrier $backupCarrier
  * @param \Magento\Framework\Registry $registry
  * @param Client\WebServiceClientFactory $shipperWSClientFactory
  * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory
  * @param \Magento\Shipping\Model\Rate\ResultFactory $resultFactory
  * @param \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory
  * @param \ShipperHQ\Lib\Rate\Helper $shipperWSRateHelper
  * @param \ShipperHQ\Lib\Rate\ConfigSettingsFactory $configSettingsFactory
  * @param \Magento\Checkout\Model\Session $checkoutSession
  * @param \ShipperHQ\Shipper\Helper\Package $packageHelper
  * @param array $data
  */
 public function __construct(\ShipperHQ\Shipper\Helper\Data $shipperDataHelper, \ShipperHQ\Shipper\Helper\Rest $restHelper, \ShipperHQ\Shipper\Helper\CarrierCache $carrierCache, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \ShipperHQ\Shipper\Helper\LogAssist $shipperLogger, \Psr\Log\LoggerInterface $logger, Config $configHelper, Processor\ShipperMapper $shipperMapper, Processor\CarrierConfigHandler $carrierConfigHandler, Processor\BackupCarrier $backupCarrier, \Magento\Framework\Registry $registry, \ShipperHQ\WS\Client\WebServiceClientFactory $shipperWSClientFactory, \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Magento\Shipping\Model\Rate\ResultFactory $resultFactory, \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory, \ShipperHQ\Shipper\Helper\CarrierGroup $carrierGroupHelper, \ShipperHQ\Lib\Rate\Helper $shipperLibRateHelper, \ShipperHQ\Lib\Rate\ConfigSettingsFactory $configSettingsFactory, \Magento\Framework\Event\ManagerInterface $eventManager, \ShipperHQ\Lib\AllowedMethods\Helper $allowedMethodsHelper, \Magento\Checkout\Model\Session $checkoutSession, \ShipperHQ\Shipper\Helper\Package $packageHelper, array $data = [])
 {
     $this->shipperDataHelper = $shipperDataHelper;
     $this->restHelper = $restHelper;
     $this->configHelper = $configHelper;
     $this->shipperMapper = $shipperMapper;
     $this->rateFactory = $resultFactory;
     $this->rateMethodFactory = $rateMethodFactory;
     $this->registry = $registry;
     $this->shipperLogger = $shipperLogger;
     $this->shipperWSClientFactory = $shipperWSClientFactory;
     $this->carrierConfigHandler = $carrierConfigHandler;
     $this->carrierCache = $carrierCache;
     $this->backupCarrier = $backupCarrier;
     $this->carrierGroupHelper = $carrierGroupHelper;
     $this->shipperRateHelper = $shipperLibRateHelper;
     $this->configSettingsFactory = $configSettingsFactory;
     $this->eventManager = $eventManager;
     $this->allowedMethodsHelper = $allowedMethodsHelper;
     $this->checkoutSession = $checkoutSession;
     $this->packageHelper = $packageHelper;
     parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data);
 }