本文整理汇总了PHP中Mage_Sales_Model_Order::getAllItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order::getAllItems方法的具体用法?PHP Mage_Sales_Model_Order::getAllItems怎么用?PHP Mage_Sales_Model_Order::getAllItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order::getAllItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkRelation
public function checkRelation(Mage_Sales_Model_Order $order)
{
/**
* Check customer existing
*/
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
if (!$customer->getId()) {
$this->_getSession()->addNotice(Mage::helper('adminhtml')->__(' The customer does not exist in the system anymore.'));
}
/**
* Check Item products existing
*/
$productIds = array();
foreach ($order->getAllItems() as $item) {
$productIds[] = $item->getProductId();
}
$productCollection = Mage::getModel('catalog/product')->getCollection()->addIdFilter($productIds)->load();
$hasBadItems = false;
foreach ($order->getAllItems() as $item) {
if (!$productCollection->getItemById($item->getProductId())) {
$this->_getSession()->addError(Mage::helper('adminhtml')->__('The item %s (SKU %s) does not exist in the catalog anymore.', $item->getName(), $item->getSku()));
$hasBadItems = true;
}
}
if ($hasBadItems) {
$this->_getSession()->addError(Mage::helper('adminhtml')->__('Some of the ordered items do not exist in the catalog anymore and will be removed if you try to edit the order.'));
}
return $this;
}
示例2: createReservationDocument
public function createReservationDocument($event)
{
$order = new Mage_Sales_Model_Order();
$incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order->loadByIncrementId($incrementId);
$orderData = $order->getData();
$customerID = sprintf("WEBC%010d", $order['customer_id']);
$orderDate = date('Y-m-d H:i:s');
$XML = "\n <TrumpasPardRezDok>\n <sKlientas>{$customerID}</sKlientas>\n <tData>{$orderDate}</tData>\n <sSerija></sSerija>\n <sDokumentas></sDokumentas>\n <sValiuta>{$orderData['order_currency_code']}</sValiuta>";
$VAT = 21;
foreach ($order->getAllItems() as $item) {
$children = $item->getChildrenItems();
if (!empty($children)) {
continue;
// bundle
}
$itemData = $item->getData();
$priceVat = round($itemData['price_incl_tax'], 4);
$priceNoVat = round($priceVat / ($VAT / 100 + 1), 4);
$priceVatValue = round($priceVat - $priceNoVat, 4);
$qty = intval($itemData['qty_ordered']);
$XML .= "\n <PardDokPrekeDetEil>\n <sKodas>{$itemData['sku']}</sKodas>\n <sPavadinimas>{$itemData['name']}</sPavadinimas>\n <sSandelis>CENTR.</sSandelis>\n <nKiekis>{$qty}</nKiekis>\n <dSumaL>{$priceNoVat}</dSumaL>\n <dSumaV>{$priceNoVat}</dSumaV>\n <dSumaPVMV>{$priceVatValue}</dSumaPVMV>\n <dSumaPVML>{$priceVatValue}</dSumaPVML>\n </PardDokPrekeDetEil>";
}
$shippingAmountVat = round($order->getShippingAmount(), 4);
$shippingAmountNoVat = round($shippingAmountVat / ($VAT / 100 + 1), 4);
$shippingVatValue = round($shippingAmountVat - $shippingAmountNoVat, 4);
$XML .= "\n <PardDokPaslaugaDetEil>\n <sKodas>TRANSPORTAV</sKodas>\n <nKiekis>100</nKiekis>\n <dSumaV>{$shippingAmountNoVat}</dSumaV>\n <dSumaL>{$shippingAmountNoVat}</dSumaL>\n <dSumaPVMV>{$shippingVatValue}</dSumaPVMV>\n <dSumaPVML>{$shippingVatValue}</dSumaPVML>\n \t </PardDokPaslaugaDetEil>\n ";
$XML .= "</TrumpasPardRezDok>";
/** @var $fvs Srautas_Finvalda_Webservice */
$fvs = Mage::getSingleton('finvalda/webservice');
$fvs->InsertNewOperation(array('ItemClassName' => 'TrumpasPardRezDok', 'sParametras' => 'PIRMAS', 'xmlString' => $XML));
return $this;
}
示例3: prepareCreditmemo
/**
* Prepare order creditmemo based on order items and requested params
*
* @param array $data
* @return Mage_Sales_Model_Order_Creditmemo
*/
public function prepareCreditmemo($data = array())
{
$totalQty = 0;
$creditmemo = $this->_convertor->toCreditmemo($this->_order);
$qtys = isset($data['qtys']) ? $data['qtys'] : array();
foreach ($this->_order->getAllItems() as $orderItem) {
if (!$this->_canRefundItem($orderItem, $qtys)) {
continue;
}
$item = $this->_convertor->itemToCreditmemoItem($orderItem);
if ($orderItem->isDummy()) {
$qty = 1;
$orderItem->setLockedDoShip(true);
} else {
if (isset($qtys[$orderItem->getId()])) {
$qty = (double) $qtys[$orderItem->getId()];
} elseif (!count($qtys)) {
$qty = $orderItem->getQtyToRefund();
} else {
continue;
}
}
$totalQty += $qty;
$item->setQty($qty);
$creditmemo->addItem($item);
}
$creditmemo->setTotalQty($totalQty);
$this->_initCreditmemoData($creditmemo, $data);
$creditmemo->collectTotals();
return $creditmemo;
}
示例4: setItemstoSend
/**
* Process order items to send to MailChimp
*
* @access private
* @return Ebizmarts_MageMonkey_Model_Ecommerce360
*/
private function setItemstoSend()
{
foreach ($this->_order->getAllItems() as $item) {
$mcitem = array();
$product = Mage::getSingleton('catalog/product')->load($item->getProductId());
if (in_array($product->getTypeId(), $this->_productsToSkip) && $product->getPriceType() == 0) {
if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
$this->_auxPrice = $item->getPrice();
}
continue;
}
$mcitem['product_id'] = $product->getEntityId();
$mcitem['sku'] = $product->getSku();
$mcitem['product_name'] = $product->getName();
$names = array();
$cat_ids = $product->getCategoryIds();
if (is_array($cat_ids) && count($cat_ids) > 0) {
$category = Mage::getModel('catalog/category')->load($cat_ids[0]);
$mcitem['category_id'] = $cat_ids[0];
$names[] = $category->getName();
while ($category->getParentId() && $category->getParentId() != 1) {
$category = Mage::getModel('catalog/category')->load($category->getParentId());
$names[] = $category->getName();
}
}
$mcitem['category_name'] = count($names) ? implode(" - ", array_reverse($names)) : 'None';
$mcitem['qty'] = $item->getQtyOrdered();
$mcitem['cost'] = $this->_auxPrice > 0 ? $this->_auxPrice : $item->getPrice();
$this->_info['items'][] = $mcitem;
$this->_auxPrice = 0;
}
return $this;
}
示例5: getAllOrderItems
/**
* @param Mage_Sales_Model_Abstract $entity
* @param Mage_Sales_Model_Order $order
* @param string $context
*
* @return mixed
*/
protected function getAllOrderItems($entity, $order, $context)
{
$this->_order = $order;
if ($context == self::TYPE_RS) {
return $entity->getAllItems();
}
return $order->getAllItems();
}
示例6: _buildInvoiceFor
/**
* Create invoice
*
* @param Mage_Sales_Model_Order $order
* @return Mage_Sales_Model_Order_Invoice
*/
protected function _buildInvoiceFor($order)
{
$items = array();
foreach ($order->getAllItems() as $item) {
$items[$item->getId()] = $item->getQtyOrdered();
}
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice($items);
$invoice->setEmailSent(true)->register();
return $invoice;
}
示例7: buckaroo3extended_request_addcustomvars
/**
* @param Varien_Event_Observer $observer
*
* @return $this
*/
public function buckaroo3extended_request_addcustomvars(Varien_Event_Observer $observer)
{
if ($this->_isChosenMethod($observer) === false) {
return $this;
}
$request = $observer->getRequest();
$this->_billingInfo = $request->getBillingInfo();
$this->_order = $request->getOrder();
$vars = $request->getVars();
if (Mage::getStoreConfig('buckaroo/buckaroo3extended_' . $this->_method . '/use_creditmanagement', Mage::app()->getStore()->getStoreId())) {
$this->_addCustomerVariables($vars);
$this->_addCreditManagement($vars);
$this->_addAdditionalCreditManagementVariables($vars);
}
$shippingCosts = round($this->_order->getBaseShippingInclTax(), 2);
$discount = null;
if (Mage::helper('buckaroo3extended')->isEnterprise()) {
if ((double) $this->_order->getGiftCardsAmount() > 0) {
$discount = (double) $this->_order->getGiftCardsAmount();
}
}
if (abs((double) $this->_order->getDiscountAmount()) > 0) {
$discount += abs((double) $this->_order->getDiscountAmount());
}
$array = array('Discount' => $discount, 'ShippingCosts' => $shippingCosts, 'ShippingSuppression' => 'TRUE');
$products = $this->_order->getAllItems();
$group = array();
foreach ($products as $item) {
/** @var Mage_Sales_Model_Order_Item $item */
if (empty($item) || $item->hasParentItemId()) {
continue;
}
// Changed calculation from unitPrice to orderLinePrice due to impossible to recalculate unitprice,
// because of differences in outcome between TAX settings: Unit, OrderLine and Total.
// Quantity will always be 1 and quantity ordered will be in the article description.
$productPrice = $item->getBasePrice() * $item->getQtyOrdered() + $item->getBaseTaxAmount() + $item->getBaseHiddenTaxAmount();
$productPrice = round($productPrice, 2);
$article['ArticleDescription']['value'] = (int) $item->getQtyOrdered() . 'x ' . $item->getName();
$article['ArticleQuantity']['value'] = 1;
$article['ArticleUnitPrice']['value'] = (string) $productPrice;
$group[] = $article;
}
$paymentFeeArray = $this->_getPaymentFeeLine();
if (false !== $paymentFeeArray && is_array($paymentFeeArray)) {
$group[] = $paymentFeeArray;
}
$array['Articles'] = $group;
if (array_key_exists('customVars', $vars) && array_key_exists($this->_method, $vars['customVars']) && is_array($vars['customVars'][$this->_method])) {
$vars['customVars'][$this->_method] = array_merge($vars['customVars'][$this->_method], $array);
} else {
$vars['customVars'][$this->_method] = $array;
}
$request->setVars($vars);
return $this;
}
示例8: setItemstoSend
/**
* Process order items to send to MailChimp
*
* @access private
* @return Ebizmarts_MageMonkey_Model_Ecommerce360
*/
private function setItemstoSend($storeId)
{
foreach ($this->_order->getAllItems() as $item) {
$mcitem = array();
$product = Mage::getModel('catalog/product')->load($item->getProductId());
if (in_array($product->getTypeId(), $this->_productsToSkip) && $product->getPriceType() == 0) {
if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
$this->_auxPrice = $item->getBasePrice();
}
continue;
}
$mcitem['product_id'] = $product->getEntityId();
$mcitem['sku'] = $product->getSku();
$mcitem['product_name'] = $product->getName();
$attributesToSend = explode(',', Mage::getStoreConfig(Ebizmarts_MageMonkey_Model_Config::ECOMMERCE360_ATTRIBUTES, $storeId));
$attributes = $product->getAttributes();
$productAttributes = '';
$pipe = false;
foreach ($attributes as $attribute) {
if ($pipe) {
$productAttributes .= '|';
}
if (in_array($attribute->getAttributeCode(), $attributesToSend) && is_string($attribute->getFrontend()->getValue($product)) && trim($attribute->getFrontend()->getValue($product)) != '') {
$productAttributes .= $attribute->getAttributeCode() . ':' . $attribute->getFrontend()->getValue($product);
$pipe = true;
} else {
$pipe = false;
}
}
if ($productAttributes) {
$mcitem['product_name'] .= '[' . $productAttributes . ']';
}
$names = array();
$cat_ids = $product->getCategoryIds();
if (is_array($cat_ids) && count($cat_ids) > 0) {
$category = Mage::getModel('catalog/category')->load($cat_ids[0]);
$mcitem['category_id'] = $cat_ids[0];
$names[] = $category->getName();
while ($category->getParentId() && $category->getParentId() != 1) {
$category = Mage::getModel('catalog/category')->load($category->getParentId());
$names[] = $category->getName();
}
}
if (!isset($mcitem['category_id'])) {
$mcitem['category_id'] = 0;
}
$mcitem['category_name'] = count($names) ? implode(" - ", array_reverse($names)) : 'None';
$mcitem['qty'] = $item->getQtyOrdered();
$mcitem['cost'] = $this->_auxPrice > 0 ? $this->_auxPrice : $item->getBasePrice();
$this->_info['items'][] = $mcitem;
$this->_auxPrice = 0;
}
return $this;
}
示例9: _render
/**
* (re)Render all items and totals
*/
protected function _render()
{
if (!$this->_shouldRender) {
return;
}
// regular items from the sales entity
$this->_items = array();
foreach ($this->_salesEntity->getAllItems() as $item) {
if (!$item->getParentItem()) {
$this->_addRegularItem($item);
}
}
end($this->_items);
$lastRegularItemKey = key($this->_items);
// regular totals
$shippingDescription = '';
if ($this->_salesEntity instanceof Mage_Sales_Model_Order) {
$shippingDescription = $this->_salesEntity->getShippingDescription();
$this->_totals = array(self::TOTAL_SUBTOTAL => $this->_salesEntity->getBaseSubtotal(), self::TOTAL_TAX => $this->_salesEntity->getBaseTaxAmount(), self::TOTAL_SHIPPING => $this->_salesEntity->getBaseShippingAmount(), self::TOTAL_DISCOUNT => abs($this->_salesEntity->getBaseDiscountAmount()));
$this->_applyHiddenTaxWorkaround($this->_salesEntity);
} else {
$address = $this->_salesEntity->getIsVirtual() ? $this->_salesEntity->getBillingAddress() : $this->_salesEntity->getShippingAddress();
$shippingDescription = $address->getShippingDescription();
$this->_totals = array(self::TOTAL_SUBTOTAL => $this->_salesEntity->getBaseSubtotal(), self::TOTAL_TAX => $address->getBaseTaxAmount(), self::TOTAL_SHIPPING => $address->getBaseShippingAmount(), self::TOTAL_DISCOUNT => abs($address->getBaseDiscountAmount()));
$this->_applyHiddenTaxWorkaround($address);
}
$originalDiscount = $this->_totals[self::TOTAL_DISCOUNT];
// arbitrary items, total modifications
Mage::dispatchEvent('paypal_prepare_line_items', array('paypal_cart' => $this));
// distinguish original discount among the others
if ($originalDiscount > 0.0001 && isset($this->_totalLineItemDescriptions[self::TOTAL_DISCOUNT])) {
$this->_totalLineItemDescriptions[self::TOTAL_DISCOUNT][] = Mage::helper('sales')->__('Discount (%s)', Mage::app()->getStore()->convertPrice($originalDiscount, true, false));
}
// discount, shipping as items
if ($this->_isDiscountAsItem && $this->_totals[self::TOTAL_DISCOUNT]) {
$this->addItem(Mage::helper('paypal')->__('Discount'), 1, -1.0 * $this->_totals[self::TOTAL_DISCOUNT], $this->_renderTotalLineItemDescriptions(self::TOTAL_DISCOUNT));
}
$shippingItemId = $this->_renderTotalLineItemDescriptions(self::TOTAL_SHIPPING, $shippingDescription);
if ($this->_isShippingAsItem && (double) $this->_totals[self::TOTAL_SHIPPING]) {
$this->addItem(Mage::helper('paypal')->__('Shipping'), 1, (double) $this->_totals[self::TOTAL_SHIPPING], $shippingItemId);
}
// compound non-regular items into subtotal
foreach ($this->_items as $key => $item) {
if ($key > $lastRegularItemKey && $item->getAmount() != 0) {
$this->_totals[self::TOTAL_SUBTOTAL] += $item->getAmount();
}
}
$this->_validate();
// if cart items are invalid, prepare cart for transfer without line items
if (!$this->_areItemsValid) {
$this->removeItem($shippingItemId);
}
$this->_shouldRender = false;
}
示例10: updateInvoicedItems
/**
* Set correct totals for the items which have just been invoiced
*
* @param Mage_Sales_Model_Order $order
* @return $this
*/
public function updateInvoicedItems(Mage_Sales_Model_Order $order)
{
foreach ($order->getAllItems() as $orderItem) {
$orderItem->setTaxInvoiced($orderItem->getTaxAmount());
$orderItem->setBaseTaxInvoiced($orderItem->getBaseTaxAmount());
$orderItem->setRowInvoiced($orderItem->getRowTotal());
$orderItem->setBaseRowInvoiced($orderItem->getBaseRowTotal());
$orderItem->save();
}
return $this;
}
示例11: getScript
public function getScript()
{
$request = Mage::app()->getRequest();
$module = $request->getModuleName();
$controller = $request->getControllerName();
$action = $request->getActionName();
$flag = false;
$currency = Mage::app()->getStore()->getCurrentCurrencyCode();
$script = "<script>var apiKey = '" . $this->getKey() . "';</script>" . "\n";
if ($module == 'checkout' && $controller == 'onestep' && $action == 'success' || $module == 'checkout' && $controller == 'onepage' && $action == 'success' || $module == 'securecheckout' && $controller == 'index' && $action == 'success' || $module == 'customdownloadable' && $controller == 'onepage' && $action == 'success' || $module == 'onepagecheckout' && $controller == 'index' && $action == 'success' || $module == 'onestepcheckout' && $controller == 'index' && $action == 'success') {
$order = new Mage_Sales_Model_Order();
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order->loadByIncrementId($orderId);
// Load order details
$order_total = round($order->getGrandTotal(), 2);
// Get grand total
$order_coupon = $order->getCouponCode();
// Get coupon used
$items = $order->getAllItems();
// Get items info
$cartInfo = array();
// Convert object to string
foreach ($items as $item) {
$product = Mage::getModel('catalog/product')->load($item->getProductId());
$name = $item->getName();
$qty = $item->getQtyToInvoice();
$cartInfo[] = array('id' => $item->getProductId(), 'name' => $name, 'quantity' => $qty);
}
$cartInfoString = serialize($cartInfo);
$cartInfoString = addcslashes($cartInfoString, "'");
$order_name = $order->getCustomerName();
// Get customer's name
$order_email = $order->getCustomerEmail();
// Get customer's email id
// Call invoiceRefiral function
$scriptAppend = "<script>whenAvailable('invoiceRefiral',function(){invoiceRefiral('{$order_total}','{$order_total}','{$order_coupon}','{$cartInfoString}','{$order_name}','{$order_email}','{$orderId}', '{$currency}')});</script>" . "\n";
if ($this->debug()) {
$scriptAppend .= "<script>console.log('Module: " . $module . ", Controller: " . $controller . ", Action: " . $action . "');</script>";
$scriptAppend .= "<script>console.log('Total: " . $order_total . ", Coupon: " . $order_coupon . ", Cart: " . $cartInfoString . ", Name: " . $order_name . ", Email: " . $order_email . ", Id: " . $orderId . ", Currency: " . $currency . "');</script>";
}
$script .= '<script>var showButton = false;</script>' . "\n";
} else {
if ($this->debug()) {
$scriptAppend = "<script>console.log('Module: " . $module . ", Controller: " . $controller . ", Action: " . $action . "');</script>";
} else {
$scriptAppend = '';
}
$script .= '<script>var showButton = true;</script>' . "\n";
}
$script .= '<script type="text/javascript">(function e(){var e=document.createElement("script");e.type="text/javascript",e.async=true,e.src="//rfer.co/api/v1/js/all.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})();</script>' . "\n";
return $script . $scriptAppend;
}
示例12: updateStatus
/**
* Update the status of catalog items if their inventory is below the threshold
*
* @param Mage_Sales_Model_Order $order order object
*
* @return boolean
*/
public function updateStatus($order)
{
// get order items
$orderItems = $order->getAllItems();
// get current store
$storeId = Mage::app()->getStore()->getStoreId();
foreach ($orderItems as $item) {
$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $item->getSku());
$_product = Mage::getModel('catalog/product')->load($_product->getId());
$_availableQty = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
if ($_availableQty <= $_product->getUnmInventoryThreshold()) {
Mage::getModel('catalog/product_status')->updateProductStatus($_product->getId(), $storeId, Mage_Catalog_Model_Product_Status::STATUS_DISABLED);
}
}
}
示例13: checkQuoteItems
/**
* Check and restore quote items which have been deleted from database
*
* @param $quoteId
* @param Mage_Sales_Model_Order $order
* @internal param \Mage_Sales_Model_Quote $quote
* @return $this
*/
public function checkQuoteItems($quoteId, Mage_Sales_Model_Order $order)
{
if ($this->_quoteItemsAlreadyChecked) {
return $this;
}
foreach ($order->getAllItems() as $orderItem) {
$quoteItemId = $orderItem->getQuoteItemId();
$quoteItem = Mage::getModel('sales/quote_item')->load($quoteItemId);
if ($quoteItem && $quoteItem->getId()) {
continue;
}
$product = Mage::getModel('catalog/product')->setStoreId($order->getStoreId())->load($orderItem->getProductId());
$newQuoteItem = Mage::getModel('sales/convert_order')->itemToQuoteItem($orderItem);
$newQuoteItem->setQuoteId($quoteId)->setProduct($product)->save();
$orderItem->setQuoteItemId($newQuoteItem->getItemId())->save();
}
$this->_quoteItemsAlreadyChecked = true;
return $this;
}
示例14: _ifProductsAvailable
/**
* Return if products are available for current admin
*
* @param Mage_Sales_Model_Order $model
* @return bool
*/
protected function _ifProductsAvailable($model)
{
$products = $model->getAllItems();
$allProductsAvailable = true;
foreach ($products as $product) {
try {
$this->_factory->getModel('catalog/product')->load($product->getProductId());
} catch (Enterprise_AdminGws_Controller_Exception $e) {
$allProductsAvailable = false;
}
if (!$allProductsAvailable) {
break;
}
}
return $allProductsAvailable;
}
示例15: _saveOrder
/** Saves the Order, to complete the full life-cycle of the Order
* Order status will now show as Complete
* @param $order Mage_Sales_Model_Order
*/
protected function _saveOrder(Mage_Sales_Model_Order $order)
{
$totalQtyOrdered = (double) $order->getTotalQtyOrdered();
$qtyShipped = '';
foreach ($order->getAllItems() as $_eachItem) {
$qtyShipped += (double) $_eachItem->getQtyShipped();
}
if ($qtyShipped < $totalQtyOrdered) {
$order->setData('state', Mage_Sales_Model_Order::STATE_PROCESSING);
$order->setData('status', Mage_Sales_Model_Order::STATE_PROCESSING);
} else {
$order->setData('state', Mage_Sales_Model_Order::STATE_COMPLETE);
$order->setData('status', Mage_Sales_Model_Order::STATE_COMPLETE);
}
$order->save();
return $this;
}