本文整理汇总了PHP中Mage_Sales_Model_Order_Item::getQtyOrdered方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Item::getQtyOrdered方法的具体用法?PHP Mage_Sales_Model_Order_Item::getQtyOrdered怎么用?PHP Mage_Sales_Model_Order_Item::getQtyOrdered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Item
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Item::getQtyOrdered方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: crateFromOrderItem
public static function crateFromOrderItem(Mage_Sales_Model_Order_Item $orderItem)
{
$productId = $orderItem->getProductId();
/** @var Mage_Catalog_Model_Product $product */
$product = Mage::getModel('catalog/product')->load($productId);
$discounts = $product->getPrice() - $product->getFinalPrice();
$aArticle = new self();
$aArticle->id = $productId;
$aArticle->name = $orderItem->getName();
$aArticle->url = $product->getProductUrl();
$aArticle->image_url = $product->getImageUrl();
$aArticle->quantity = intval($orderItem->getQtyOrdered());
$aArticle->price = Aplazame_Sdk_Serializer_Decimal::fromFloat($orderItem->getPrice() + $discounts);
$aArticle->description = substr($product->getDescription(), 0, 255);
$aArticle->tax_rate = Aplazame_Sdk_Serializer_Decimal::fromFloat(self::getProductTaxRate($product));
$aArticle->discount = Aplazame_Sdk_Serializer_Decimal::fromFloat($discounts);
return $aArticle;
}
示例2: addOrderItem
/**
* Convert order item to quote item
*
* @param Mage_Sales_Model_Order_Item $orderItem
* @param mixed $qtyFlag if is null set product qty like in order
* @return Mage_Checkout_Model_Cart
*/
public function addOrderItem($orderItem, $qtyFlag = null)
{
/* @var $orderItem Mage_Sales_Model_Order_Item */
if (is_null($orderItem->getParentItem())) {
$product = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->load($orderItem->getProductId());
if (!$product->getId()) {
return $this;
}
$info = $orderItem->getProductOptionByCode('info_buyRequest');
$info = new Varien_Object($info);
if (is_null($qtyFlag)) {
$info->setQty($orderItem->getQtyOrdered());
} else {
$info->setQty(1);
}
$this->addProduct($product, $info);
}
return $this;
}
示例3: addQuantityToXml
/**
* Add item quantities to the XML
*
* @param Mage_Core_Block_Template $renderer Product renderer
* @param Mage_XmlConnect_Model_Simplexml_Element $quantityXml
* @param Mage_Sales_Model_Order_Item $item
* @return null
*/
public function addQuantityToXml(Mage_Core_Block_Template $renderer, Mage_XmlConnect_Model_Simplexml_Element $quantityXml, Mage_Sales_Model_Order_Item $item)
{
$qty = 1 * $item->getQtyOrdered();
if ($qty > 0) {
$quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Ordered')));
}
$qty = 1 * $item->getQtyShipped();
if ($qty > 0) {
$quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Shipped')));
}
$qty = 1 * $item->getQtyCanceled();
if ($qty > 0) {
$quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Canceled')));
}
$qty = 1 * $item->getQtyRefunded();
if ($qty > 0) {
$quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Refunded')));
}
}
示例4: _calculateRefundedQty
/**
* Calculate refund qty
*
* @param Varien_Object $dataObject
* @param Mage_Sales_Model_Order_Item $orderItem
* @return array [not_ship, shipped, total, had_refunded]
*/
protected function _calculateRefundedQty($dataObject, $orderItem)
{
$creditMemo = $dataObject->getCreditmemoObject();
$order = $dataObject->getOrder();
$parentItemId = $orderItem->getParentItemId();
$refundItem = $creditMemo->getItemByOrderId($orderItem->getId());
$parentItem = $parentItemId ? $creditMemo->getItemByOrderId($parentItemId) : false;
if (is_bool($refundItem)) {
$refundQty = $parentItem ? $parentItem->getQty() : 0;
} else {
$refundQty = $parentItem ? $parentItem->getQty() * $refundItem->getQty() : $refundItem->getQty();
}
$oldCreditmemos = $order->getCreditmemosCollection();
/* total refuned qty before created this creditmemo */
$hadRefundedQty = 0;
if (count($oldCreditmemos)) {
foreach ($oldCreditmemos as $oldCreditmemo) {
if ($oldCreditmemo->getId() == $creditMemo->getId()) {
continue;
}
$item = $oldCreditmemo->getItemByOrderId($orderItem->getId());
if ($item) {
$parentItem = $orderItem->getParentItemId() ? $oldCreditmemo->getItemByOrderId($orderItem->getParentItemId()) : false;
$hadRefundedQty += $parentItem ? $parentItem->getQty() * $item->getQty() : $item->getQty();
}
}
}
/* calculate shipped qty */
$shippedQty = $orderItem->getQtyShipped();
if ($orderItem->getParentItemId()) {
$parentOrderItem = $order->getItemById($orderItem->getParentItemId());
if ($parentOrderItem && $parentOrderItem->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
$shippedQty = $parentOrderItem->getQtyShipped();
}
}
/* calculate canceled qty */
$canceledQty = $orderItem->getQtyCanceled();
if ($orderItem->getParentItemId()) {
$parentOrderItem = $order->getItemById($orderItem->getParentItemId());
if ($parentOrderItem && $parentOrderItem->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
$canceledQty = $parentOrderItem->getQtyCanceled();
}
}
/* total qty which we need to ship before created this credit memo */
$needToShipQty = $orderItem->getQtyOrdered() - $shippedQty - $hadRefundedQty - $canceledQty;
$needToShipQty = $needToShipQty >= 0 ? $needToShipQty : 0;
/* separate refund qty to qty of not_ship items & qty of shipped items */
$refundQtys = array('not_ship' => min($refundQty, $needToShipQty), 'shipped' => $refundQty - min($refundQty, $needToShipQty), 'total' => $refundQty, 'had_refunded' => $hadRefundedQty);
return $refundQtys;
}
示例5: sync
/**
* Sync the given order item to Klevu. Returns true on successful sync and
* the error message otherwise.
*
* @param Mage_Sales_Model_Order_Item $item
*
* @return bool|string
*/
protected function sync($item)
{
if (!$this->getApiKey($item->getStoreId())) {
return "Klevu Search is not configured for this store.";
}
$parent = null;
if ($item->getParentItemId()) {
$parent = Mage::getModel("sales/order_item")->load($item->getParentItemId());
}
$response = Mage::getModel("klevu_search/api_action_producttracking")->execute(array("klevu_apiKey" => $this->getApiKey($item->getStoreId()), "klevu_type" => "checkout", "klevu_productId" => Mage::helper("klevu_search")->getKlevuProductId($item->getProductId(), $parent ? $parent->getProductId() : 0), "klevu_unit" => $item->getQtyOrdered() ? $item->getQtyOrdered() : ($parent ? $parent->getQtyOrdered() : null), "klevu_salePrice" => $item->getPriceInclTax() ? $item->getPriceInclTax() : ($parent ? $parent->getPriceInclTax() : null), "klevu_currency" => $this->getStoreCurrency($item->getStoreId()), "klevu_shopperIP" => $this->getOrderIP($item->getOrderId())));
if ($response->isSuccessful()) {
return true;
} else {
return $response->getMessage();
}
}
示例6: initFromOrderItem
/**
* Initialize creation data from existing order Item
*
* @param Mage_Sales_Model_Order_Item $orderItem
* @return Mage_Sales_Model_Quote_Item | string
*/
public function initFromOrderItem(Mage_Sales_Model_Order_Item $orderItem, $qty = 1)
{
if (!$orderItem->getId()) {
return $this;
}
$product = Mage::getModel('catalog/product')->setStoreId($this->getSession()->getStoreId())->load($orderItem->getProductId());
if ($product->getId()) {
$info = $orderItem->getProductOptionByCode('info_buyRequest');
$info = new Varien_Object($info);
$product->setSkipCheckRequiredOption(true);
$info->setQty($orderItem->getQtyOrdered());
$item = $this->getQuote()->addProduct($product, $info);
if (is_string($item)) {
return $item;
}
//$item->setQty($qty);
if ($additionalOptions = $orderItem->getProductOptionByCode('additional_options')) {
$item->addOption(new Varien_Object(array('product' => $item->getProduct(), 'code' => 'additional_options', 'value' => serialize($additionalOptions))));
}
Mage::dispatchEvent('sales_convert_order_item_to_quote_item', array('order_item' => $orderItem, 'quote_item' => $item));
return $item;
}
return $this;
}
示例7: getItemPrice
/**
* Gets the item price
*
* @param Mage_Sales_Model_Order_Item $item
* @param string $priceAttr
* @param boolean $inclTaxes
* @param boolean $inclDiscounts
* @return float
*/
public function getItemPrice($item, $priceAttr, $inclTaxes, $inclDiscounts)
{
$base = $priceAttr == 'base' ? 'base_' : '';
$rowTotal = $item->getData("{$base}row_total");
$quantity = $item->getQtyOrdered();
if ($inclTaxes) {
$rowTotal += $item->getData("{$base}tax_amount");
}
if ($inclDiscounts) {
$rowTotal -= $item->getData("{$base}discount_amount");
}
return !empty($quantity) ? max((double) ($rowTotal / $quantity), 0.0) : 0.0;
}
示例8: cancelOrderItem
/**
* Cancel specific qty of order item
*
* @param Mage_Sales_Model_Order_Item $orderItem
* @param null $qtyToCancel
* @return Mage_Sales_Model_Order_Item
*/
public function cancelOrderItem(Mage_Sales_Model_Order_Item $orderItem, $qtyToCancel = null)
{
if ($orderItem->getStatusId() !== Mage_Sales_Model_Order_Item::STATUS_CANCELED) {
if (is_null($qtyToCancel)) {
$qtyToCancel = $orderItem->getQtyToCancel();
}
Mage::dispatchEvent('sales_order_item_cancel', array('item' => $orderItem));
$orderItem->setQtyCanceled($orderItem->getQtyCanceled() + $qtyToCancel);
$orderItem->setTaxCanceled($orderItem->getTaxCanceled() + $orderItem->getBaseTaxAmount() * $orderItem->getQtyCanceled() / $orderItem->getQtyOrdered());
$orderItem->setHiddenTaxCanceled($orderItem->getHiddenTaxCanceled() + $orderItem->getHiddenTaxAmount() * $orderItem->getQtyCanceled() / $orderItem->getQtyOrdered());
}
return $orderItem;
}
示例9: getItemFinalPriceInclTax
/**
* Get the final price in base currency for an ordered item including
* taxes as discounts.
*
* @param Mage_Sales_Model_Order_Item $item the item model.
*
* @return float
*/
public function getItemFinalPriceInclTax(Mage_Sales_Model_Order_Item $item)
{
$quantity = (double) $item->getQtyOrdered();
$basePrice = $item->getBaseRowTotal() + $item->getBaseTaxAmount() + $item->getBaseHiddenTaxAmount() - $item->getBaseDiscountAmount();
$orderCurrencyCode = $item->getOrder()->getOrderCurrencyCode();
$baseCurrencyCode = $item->getOrder()->getBaseCurrencyCode();
if ($orderCurrencyCode != $baseCurrencyCode) {
$priceInOrderCurrency = Mage::helper('directory')->currencyConvert($basePrice, $baseCurrencyCode, $orderCurrencyCode);
} else {
$priceInOrderCurrency = $basePrice;
}
if ($quantity > 1) {
$priceInOrderCurrency = round($priceInOrderCurrency / $quantity, 2);
}
return $priceInOrderCurrency;
}
示例10: _createSimpleOrderLineData
/**
* Returns SimpleOrderLineData record
*
* @param Mage_Sales_Model_Order_Item $item
* @return array
*/
protected function _createSimpleOrderLineData(Mage_Sales_Model_Order_Item $item)
{
/** @var $product Mage_Catalog_Model_Product */
$product = Mage::getModel('catalog/product')->setStoreId($item->getStoreId())->load($item->getProductId());
$data = array('orderLineId' => null, 'itemId' => (string) $item->getId(), 'orderNumber' => (string) $this->getOrderNumber(), 'quantity' => (double) $item->getQtyOrdered(), 'productSku' => (string) $item->getSku(), 'itemDescription' => (string) ($product->getShortDescription() ? $product->getShortDescription() : $product->getDescription()), 'unitPrice' => $this->_createOrderLinePrice($item, $item->getQtyOrdered()), 'totalTaxAmount' => $this->_createCurrencyAmount($item->getTaxAmount()), 'status' => $this->_createOrderItemStatus($item), 'price' => $this->_createCurrencyAmount($item->getBaseRowTotal()), 'allDiscounts' => null, 'dateCancelled' => null, 'dateDelivered' => null, 'dateShipped' => null, 'dateReturned' => null, 'dateInvoiced' => null, 'destination' => $this->_createShipTo($item->getOrder()->getShippingAddress()), 'shipmentId' => null, 'offerId' => null, 'offerUrl' => null);
return $data;
}
示例11: getQtyOrderedFromOrderItem
/**
* Get ordered qty from order item
*
* @param \Mage_Sales_Model_Order_Item $orderItem
* @return int|float
*/
public function getQtyOrderedFromOrderItem($orderItem)
{
$qtyOrdered = 0;
if ($orderItem->getParentItemId()) {
$parentOrderItem = Mage::getModel('sales/order_item')->load($orderItem->getParentItemId());
if ($parentOrderItem && $parentOrderItem->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
$qtyOrdered = $parentOrderItem->getQtyOrdered();
}
}
$qtyOrdered = $qtyOrdered ? $qtyOrdered : $orderItem->getQtyOrdered();
return $qtyOrdered;
}