2
我试图将延期交货产品的数量添加到新订单电子邮件中发出的电子邮件模板中。Magento:获取新订单中的产品缺货数量电子邮件
到目前为止,我已经设法得到产品,但我似乎无法得到它的数量。我尝试了各种方法,但似乎没有任何工作。这里是我的最新尝试:
该文件应用程序/设计/前端/基/默认/模板/电子邮件/订单/项目/顺序/默认/ PHTML
<?php
// 1. Get Qty of Product in Store.
// 2. Get Qty of product from order
// 3. IF qty from order > qty in store then get number over
// 4. Display number over
$_sku = $this->getItem()->getSku();
$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $_sku);
//print_r($_product);
echo 'qty in shop: '.$qtyInStock = $_product->getStockItem()->getQty(); //debugging
echo 'qty ordered: '.$qtyOrdered = $_item->getQtyOrdered()*1; //debugging
?>
<?php if($qtyOrdered > $qtyInStock): $back_order = $qtyOrdered - $qtyInStock; ?>
<p>* This product is not available in the requested quantity. <?php echo $back_order; ?> of the item(s) will be backordered.</p>
<?php endif; ?>
我还没说完与逻辑呢。我只是停留在获取产品数量上。
$_product->getStockItem()->getQty();
任何帮助最受赞赏。
比利