如果 qty = 0,我如何在此代码中添加一条语句,它会停止。
我从这里得到了这段代码,但它在最后一个之后显示了一个额外的项目。
例如
https://www.emjcd.com/u?CID=1521607&OID=100000393&TYPE=type&ITEM1=401000305964&AMT1=16.9900&QTY1=1&ITEM2=401000305964&AMT2=0.0000&QTY2=0**&TYPE=347774&CURRENCY=USD&METHOD=IMG
它添加了ITEM2=401000305964&AMT2=0.0000&QTY2=0
虽然数据库和发票只有一项
<?php
$_customerId = Mage::getSingleton('customer/session')->getCustomerId();
$lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
$order = Mage::getSingleton('sales/order');
$order->load($lastOrderId);
$_totalData =$order->getData();
$_sub = $_totalData['subtotal'];//USD ==> global_currency_code,base_currency_code order_currency_code
// Incase if it is simple do this ==> https://www.emjcd.com/u?AMOUNT= $_sub;
//print_r($order); print_r($_totalData);
$_order = $this->getOrder();
$allitems = $order->getAllItems();
$index = 1;
$cjData = "";//Needed format ==> &ITEM1=3214sku&AMT1=13.49&QTY1=1&ITEM2=6577sku&AMT2=7.99&QTY2=2&
foreach($allitems as $item)
{
$cjData.="&ITEM".$index."=".$item->getSku()."&AMT".$index."=".$item->getPrice()."&QTY".$index."=".$item->getQtyToShip();
$index++;
}
?>
<div style="display:none;">
<img src="https://www.emjcd.com/u?CID=1&OID=<?php echo $this->getOrderId(); ?>&TYPE=3<?php echo $cjData; ?>&CURRENCY=USD&METHOD=IMG" height="1" width="20">
</div>