/**
  * add data from the inventory service to the order item
  *
  * @param  IOrderItem
  * @param  Mage_Sales_Model_Order_Item
  * @return self
  */
 public function injectReservationInfo(IOrderItem $itemPayload, Mage_Sales_Model_Order_Item $item)
 {
     $allocation = $this->getAllocationForItem($item);
     if ($allocation) {
         $itemPayload->setReservationId($allocation->getReservationId());
     }
     return $this;
 }
 /**
  * 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;
 }
 /**
  * Get the tax container for gifting taxes for this item.
  *
  * @return ITaxContainer
  */
 protected function _getGiftTaxContainer()
 {
     $taxContainer = $this->_orderItemPayload->getGiftPricing();
     if (!$taxContainer) {
         $taxContainer = $this->_orderItemPayload->getEmptyGiftingPriceGroup();
         $this->_orderItemPayload->setGiftPricing($taxContainer);
     }
     return $taxContainer;
 }
 /**
  * verify
  * - discounts are applied to the merchandises pricegroup
  */
 public function testBuildOrderItemsWithItemDiscounts()
 {
     $lineNumber = 1;
     $this->itemStub->setEbayEnterpriseOrderDiscountData(['1' => ['id' => '1']]);
     $handler = $this->getModelMockBuilder('ebayenterprise_order/create_orderitem')->setMethods(['loadOrderItemOptions', 'prepareShippingPriceGroup'])->setConstructorArgs([['shipping_helper' => $this->shippingHelper]])->getMock();
     $handler->expects($this->any())->method('loadOrderItemOptions')->will($this->returnValue($this->optionValueCollectionStub));
     $handler->expects($this->any())->method('prepareShippingPriceGroup')->will($this->returnSelf());
     $handler->buildOrderItem($this->payload, $this->itemStub, $this->orderStub, $this->addressStub, $lineNumber, true);
     // merchandise price group should always exist
     $pg = $this->payload->getMerchandisePricing();
     $this->assertCount(1, $pg->getDiscounts());
 }
 /**
  * fillout the shipping price group payload for the order item
  * @param  Mage_Sales_Model_Order_Address
  * @param  IOrderItem
  * @return self
  */
 protected function prepareShippingPriceGroup(Mage_Sales_Model_Order_Address $address, IOrderItem $payload)
 {
     $shippingPriceGroup = $payload->getEmptyPriceGroup();
     $shippingPriceGroup->setAmount((double) $address->getShippingAmount());
     $this->discountHelper->transferDiscounts($address, $shippingPriceGroup);
     $payload->setShippingPricing($shippingPriceGroup);
     return $this;
 }
 /**
  * get the relationship container payload
  *
  * @return IItemRelationshipContainer
  */
 protected function getRelationshipContainer()
 {
     return $this->itemPayload->getParentPayload()->getParentPayload();
 }
 /**
  * Check for customizations of an order item to reference only known order items.
  *
  * @param IOrderItem
  * @param IOrderItemIterable
  * @return self
  */
 protected function validateOrderItemCustomizations(IOrderItem $orderItem, IOrderItemIterable $orderItems)
 {
     $customizations = $orderItem->getCustomizations();
     foreach ($customizations as $customization) {
         $item = $customization->getCustomizedItem();
         $this->validateOptionalPayloadReference($item, 'customized item', $orderItems, $item);
     }
     return $this;
 }