示例#1
0
 public function handle(\Ess\M2ePro\Model\Order $order, \Magento\Sales\Model\Order\Shipment $shipment)
 {
     $trackingDetails = $this->getTrackingDetails($shipment);
     if (!$order->getChildObject()->canUpdateShippingStatus($trackingDetails)) {
         return self::HANDLE_RESULT_SKIPPED;
     }
     return $order->getChildObject()->updateShippingStatus($trackingDetails) ? self::HANDLE_RESULT_SUCCEEDED : self::HANDLE_RESULT_FAILED;
 }
示例#2
0
 public function handle(\Ess\M2ePro\Model\Order $order, \Magento\Sales\Model\Order\Shipment $shipment)
 {
     if (!$order->isComponentModeEbay()) {
         throw new \InvalidArgumentException('Invalid component mode.');
     }
     $trackingDetails = $this->getTrackingDetails($shipment);
     if (!$order->getChildObject()->canUpdateShippingStatus($trackingDetails)) {
         return self::HANDLE_RESULT_SKIPPED;
     }
     if (empty($trackingDetails)) {
         return $this->processOrder($order) ? self::HANDLE_RESULT_SUCCEEDED : self::HANDLE_RESULT_FAILED;
     }
     $itemsToShip = $this->getItemsToShip($order, $shipment);
     if (empty($itemsToShip) || count($itemsToShip) == $order->getItemsCollection()->getSize()) {
         return $this->processOrder($order, $trackingDetails) ? self::HANDLE_RESULT_SUCCEEDED : self::HANDLE_RESULT_FAILED;
     }
     $succeeded = true;
     foreach ($itemsToShip as $item) {
         if ($this->processOrderItem($item, $trackingDetails)) {
             continue;
         }
         $succeeded = false;
     }
     return $succeeded ? self::HANDLE_RESULT_SUCCEEDED : self::HANDLE_RESULT_FAILED;
 }
示例#3
0
 public function hasCurrencyConversionRate()
 {
     $store = $this->getStore();
     if (is_null($store)) {
         return true;
     }
     return $this->modelFactory->getObject('Currency')->getConvertRateFromBase($this->order->getChildObject()->getCurrency(), $store) != 0;
 }
示例#4
0
 /**
  * @param \Ess\M2ePro\Model\Order $order
  * @param \Magento\Sales\Model\Order\Shipment $shipment
  * @return int
  */
 public function handle(\Ess\M2ePro\Model\Order $order, \Magento\Sales\Model\Order\Shipment $shipment)
 {
     if (!$order->isComponentModeAmazon()) {
         throw new \InvalidArgumentException('Invalid component mode.');
     }
     $trackingDetails = $this->getTrackingDetails($shipment);
     if (!$order->getChildObject()->canUpdateShippingStatus($trackingDetails)) {
         return self::HANDLE_RESULT_SKIPPED;
     }
     $items = $this->getItemsToShip($order, $shipment);
     $trackingDetails['fulfillment_date'] = $shipment->getCreatedAt();
     $order->getChildObject()->updateShippingStatus($trackingDetails, $items);
     return self::HANDLE_RESULT_SUCCEEDED;
 }
示例#5
0
 private function createMagentoOrder(\Ess\M2ePro\Model\Order $order)
 {
     if ($order->canCreateMagentoOrder()) {
         try {
             $order->createMagentoOrder();
         } catch (\Exception $exception) {
             return;
         }
     }
     if ($order->getChildObject()->canCreatePaymentTransaction()) {
         $order->getChildObject()->createPaymentTransactions();
     }
     if ($order->getChildObject()->canCreateInvoice()) {
         $order->createInvoice();
     }
     if ($order->getChildObject()->canCreateShipment()) {
         $order->createShipment();
     }
     if ($order->getChildObject()->canCreateTracks()) {
         $order->getChildObject()->createTracks();
     }
     $order->updateMagentoOrderStatus();
 }