/** * Subtract ordered qty for product * * @param Varien_Object $item * @return Mage_CatalogInventory_Model_Stock */ public function registerItemSale(Varien_Object $item) { if ($productId = $item->getProductId()) { $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId); if ($item->getStoreId()) { $stockItem->setStoreId($item->getStoreId()); } if ($stockItem->checkQty($item->getQtyOrdered())) { $stockItem->subtractQty($item->getQtyOrdered())->save(); } } else { Mage::throwException(Mage::helper('cataloginventory')->__('Can not specify product identifier for order item')); } return $this; }
public function render(Varien_Object $row) { $img_valid = ''; if ((int) $row->getQtyOrdered() === (int) $row->getQtyShipped()) { $img_valid = '<img src="' . $this->getSkinUrl('sm/images/barcode_success.gif') . '" width="16px" height="16px" alt="Valid" />'; } return '<div id="qty-valid-' . $row->getProductId() . '" style="text-align:center;">' . $img_valid . '</div>'; }
/** * Get one line item key-value array * * @param Mage_Core_Model_Abstract $salesEntity * @param Varien_Object $item * @return array */ protected function _prepareLineItemFields(Mage_Core_Model_Abstract $salesEntity, Varien_Object $item) { if ($salesEntity instanceof Mage_Sales_Model_Order) { $qty = $item->getQtyOrdered(); $amount = $item->getBasePrice(); } else { $qty = $item->getTotalQty(); $amount = $item->getBaseCalculationPrice(); } // workaround in case if item subtotal precision is not compatible with PayPal (.2) $subAggregatedLabel = ''; if ((double) $amount - round((double) $amount, 2)) { $amount = $amount * $qty; $subAggregatedLabel = ' x' . $qty; $qty = 1; } return array('id' => $item->getSku(), 'name' => $item->getName() . $subAggregatedLabel, 'qty' => $qty, 'amount' => (double) $amount); }
public function renderExport(Varien_Object $_item) { $res = ''; $prefix = ','; $separator = ':'; $res .= Mage::helper('mageworx_customerplus')->__('Ordered') . $separator . $_item->getQtyOrdered() * 1; if ((double) $_item->getQtyInvoiced()) { $res .= $prefix . Mage::helper('mageworx_customerplus')->__('Invoiced') . $separator . $_item->getQtyInvoiced() * 1; } if ((double) $_item->getQtyShipped()) { $res .= $prefix . Mage::helper('mageworx_customerplus')->__('Shipped') . $separator . $_item->getQtyShipped() * 1; } if ((double) $_item->getQtyRefunded()) { $res .= $prefix . Mage::helper('mageworx_customerplus')->__('Refunded') . $separator . $_item->getQtyRefunded() * 1; } if ((double) $_item->getQtyCanceled()) { $res .= $prefix . Mage::helper('mageworx_customerplus')->__('Canceled') . $separator . $_item->getQtyCanceled() * 1; } return $res; }
/** * Retrieve include tax html formated content * * @param Varien_Object $item * @return string */ public function displayPriceInclTax(Varien_Object $item) { $qty = $item->getQtyOrdered() ? $item->getQtyOrdered() : ($item->getQty() ? $item->getQty() : 1); $baseTax = $item->getTaxBeforeDiscount() ? $item->getTaxBeforeDiscount() : ($item->getTaxAmount() ? $item->getTaxAmount() : 0); $tax = $item->getBaseTaxBeforeDiscount() ? $item->getBaseTaxBeforeDiscount() : ($item->getBaseTaxAmount() ? $item->getBaseTaxAmount() : 0); $basePriceTax = 0; $priceTax = 0; if (floatval($qty)) { $basePriceTax = $item->getBasePrice() + $baseTax / $qty; $priceTax = $item->getPrice() + $tax / $qty; } return $this->displayPrices($this->getOrder()->getStore()->roundPrice($basePriceTax), $this->getOrder()->getStore()->roundPrice($priceTax)); }
/** * Get sales item (quote item, order item etc) price including tax based on row total and tax amount * * @param Varien_Object $item * @return float */ public function getPriceInclTax($item) { if ($item->getPriceInclTax()) { return $item->getPriceInclTax(); } $qty = $item->getQty() ? $item->getQty() : ($item->getQtyOrdered() ? $item->getQtyOrdered() : 1); $taxAmount = $item->getTaxAmount() + $item->getDiscountTaxCompensation(); $price = floatval($qty) ? ($item->getRowTotal() + $taxAmount) / $qty : 0; return Mage::app()->getStore()->roundPrice($price); }
/** * Add a usual line item with amount and qty * * @param Varien_Object $salesItem * @return Varien_Object */ protected function _addRegularItem(Varien_Object $salesItem) { if ($this->_salesEntity instanceof Mage_Sales_Model_Order) { $qty = (int) $salesItem->getQtyOrdered(); $amount = (double) $salesItem->getBasePrice(); // TODO: nominal item for order } else { $qty = (int) $salesItem->getTotalQty(); $amount = $salesItem->isNominal() ? 0 : (double) $salesItem->getBaseCalculationPrice(); } // workaround in case if item subtotal precision is not compatible with PayPal (.2) $subAggregatedLabel = ''; if ($amount - round($amount, 2)) { $amount = $amount * $qty; $subAggregatedLabel = ' x' . $qty; $qty = 1; } // aggregate item price if item qty * price does not match row total if ($amount * $qty != $salesItem->getBaseRowTotal()) { $amount = (double) $salesItem->getBaseRowTotal(); $subAggregatedLabel = ' x' . $qty; $qty = 1; } return $this->addItem($salesItem->getName() . $subAggregatedLabel, $qty, $amount, $salesItem->getSku()); }
/** * Get the base price of the item including tax , excluding weee * * @param Varien_Object $item * @return float */ public function getBasePriceInclTax($item) { $qty = $item->getQty() ? $item->getQty() : ($item->getQtyOrdered() ? $item->getQtyOrdered() : 1); return $qty > 0 ? $this->getBaseSubtotalInclTax($item) / $qty : 0; }
/** * Subtract ordered qty for product * * @param Varien_Object $item * @return Mage_CatalogInventory_Model_Stock */ public function registerItemSale(Varien_Object $item) { $productId = $item->getProductId(); if ($productId) { $stockItem = Mage::getModel('Mage_CatalogInventory_Model_Stock_Item')->loadByProduct($productId); if (Mage::helper('Mage_CatalogInventory_Helper_Data')->isQty($stockItem->getTypeId())) { if ($item->getStoreId()) { $stockItem->setStoreId($item->getStoreId()); } if ($stockItem->checkQty($item->getQtyOrdered()) || Mage::app()->getStore()->isAdmin()) { $stockItem->subtractQty($item->getQtyOrdered()); $stockItem->save(); } } } else { Mage::throwException(Mage::helper('Mage_CatalogInventory_Helper_Data')->__('Cannot specify product identifier for the order item.')); } return $this; }
/** * Calculating the order item gift wrapping row total when the passed in object is * a concrete 'sales/order_item' instance otherwise simply return the gift wrap price. * @param Varien_Object $item * @return float */ public function calculateGwItemRowTotal(Varien_Object $item) { $qty = $item instanceof Mage_Sales_Model_Order_Item ? $item->getQtyOrdered() : 1; return Mage::app()->getStore()->roundPrice($qty * $item->getGwPrice() + $item->getGwCardPrice()); }
public function render(Varien_Object $row) { return '<div id="qty-ordered-' . $row->getProductId() . '" style="text-align:center;">' . intval($row->getQtyOrdered()) . '</div>'; }