コード例 #1
0
 /**
  * Get an estimated delivery message for a quote item.
  *
  * @param  Mage_Sales_Model_Quote_Item
  * @return string
  */
 public function getEddMessage(Mage_Sales_Model_Quote_Item $item)
 {
     /** @var string $singularOrPluralItem */
     $singularOrPluralItem = (int) $item->getQty() > 1 ? 's' : '';
     /** @var EbayEnterprise_Inventory_Model_Details_Item | Varien_Object | null $eddItem */
     $eddItem = $this->detailService->getDetailsForItem($item) ?: $this->inventoryHelper->getStreetDateForBackorderableItem($item);
     return $eddItem ? $this->inventoryHelper->__($this->inventoryConfig->estimatedDeliveryTemplate, $singularOrPluralItem, $eddItem->getDeliveryWindowFromDate()->format('m/d/y'), $eddItem->getDeliveryWindowToDate()->format('m/d/y')) : '';
 }
コード例 #2
0
 /**
  * add data from the inventory service to the order item
  * @param  IOrderItem
  * @param  Mage_Sales_Model_Order_Item
  * @return self
  */
 public function injectShippingEstimates(IOrderItem $itemPayload, Mage_Sales_Model_Order_Item $item)
 {
     $detail = $this->detailService->getDetailsForOrderItem($item) ?: $this->helper->getOcrBackorderableEddData($item);
     if ($detail && $detail->isAvailable()) {
         $itemPayload->setEstimatedDeliveryMode(IEstimatedDeliveryDate::MODE_ENABLED)->setEstimatedDeliveryMessageType(IEstimatedDeliveryDate::MESSAGE_TYPE_DELIVERYDATE)->setEstimatedDeliveryTemplate($this->edd->getEddTemplate());
         $this->handleDateFields($itemPayload, $detail);
     }
     return $this;
 }
コード例 #3
0
 public function injectShippingOriginForItem(Mage_Sales_Model_Quote_Item_Abstract $item, Mage_Customer_Model_Address_Abstract $address)
 {
     $detail = $this->detailsService->getDetailsForItem($item);
     if (!$detail) {
         // no point hanging around if there is no result for the item
         $this->logger->debug('Details for item "{sku}" [{item_id}] not found.', $this->logContext->getMetaData(__CLASS__, ['sku' => $item->getSku(), 'item_id' => $item->getId()]));
         return;
     }
     $this->logger->debug('found details for item "{sku}" [{item_id}]', $this->logContext->getMetaData(__CLASS__, ['sku' => $item->getSku(), 'item_id' => $item->getId()]));
     $this->copyShipFromAddressTo($address, $detail);
 }
コード例 #4
0
 public function testInjectShippingOriginForItem()
 {
     $detail = $this->getModelMockBuilder('ebayenterprise_inventory/details_item')->disableOriginalConstructor()->setMethods(null)->getMock();
     EcomDev_Utils_Reflection::setRestrictedPropertyValues($detail, ['isAvailable' => true, 'shipFromLines' => 'shipFromLines', 'shipFromCity' => 'shipFromCity', 'shipFromMainDivision' => 'shipFromMainDivision', 'shipFromCountryCode' => 'shipFromCountryCode', 'shipFromPostalCode' => 'shipFromPostalCode']);
     $item = $this->getModelMock('sales/quote_item', ['getId']);
     $item->expects($this->any())->method('getId')->will($this->returnValue(1));
     $this->detailsService = $this->getModelMockBuilder('ebayenterprise_inventory/details_service')->disableOriginalConstructor()->setMethods(['getDetailsForItem'])->getMock();
     $this->detailsService->expects($this->any())->method('getDetailsForItem')->with($this->identicalTo($item))->will($this->returnValue($detail));
     $address = $this->getModelMockBuilder('customer/address_abstract')->disableOriginalConstructor()->setMethods(['addData'])->getMockForAbstractClass();
     $address->expects($this->once())->method('addData')->with($this->equalTo(['street' => 'shipFromLines', 'city' => 'shipFromCity', 'region_code' => 'shipFromMainDivision', 'country_id' => 'shipFromCountryCode', 'postcode' => 'shipFromPostalCode']))->will($this->returnSelf());
     $origin = Mage::getModel('ebayenterprise_inventory/tax_shipping_origin', ['details_service' => $this->detailsService, 'logger' => $this->logger, 'log_context' => $this->logContext]);
     $origin->injectShippingOriginForItem($item, $address);
 }
コード例 #5
0
 public function setUp()
 {
     parent::setUp();
     $this->payload = $this->mockPayload();
     $detail = $this->getModelMockBuilder('ebayenterprise_inventory/details_item')->disableOriginalConstructor()->setMethods(null)->getMock();
     EcomDev_Utils_Reflection::setRestrictedPropertyValues($detail, ['isAvailable' => true, 'deliveryWindowFromDate' => new DateTime(), 'deliveryWindowToDate' => null, 'shippingWindowFromDate' => null, 'shippingWindowToDate' => null]);
     $config = $this->buildCoreConfigRegistry(['estimatedDeliveryTemplate' => 'eddtemplate']);
     $this->helperStub = $this->getHelperMockBuilder('ebayenterprise_inventory/data')->disableOriginalConstructor()->setMethods(['getConfigModel'])->getMock();
     $this->helperStub->expects($this->any())->method('getConfigModel')->will($this->returnValue($config));
     $this->item = Mage::getModel('sales/order_item');
     $this->detailService = $this->getModelMockBuilder('ebayenterprise_inventory/details_service')->disableOriginalConstructor()->setMethods(['getDetailsForOrderItem'])->getMock();
     $this->detailService->expects($this->once())->method('getDetailsForOrderItem')->will($this->returnValue($detail));
     $this->order = Mage::getModel('sales/order');
 }