我订购了3件商品:1º产品x 1qnt2º产品x 2qnt3º产品x 1 qnt
如果我使用:
$_order = $this->getOrder();
foreach ($_order->getAllItems() as $items){
$qnttotal = $items->getQtyOrdered();
结果为1。
如果我使用:
$_order = $this->getOrder();
foreach ($_order->getAllItems() as $items){
$qty = $items->getQty();
}
导致:“NULL”。
如何退货3(产品总数)?感谢
答案 0 :(得分:1)
您可以直接从订单对象获得总数量,无需迭代。
请检查以下代码:
=Iif(Fields!MyColumn.Value = "5", True, False)
如果您想要订购总项目,请查看以下代码:
$_order = $this->getOrder();
echo 'Total qty is '.$_order->getTotalQtyOrdered();
我希望它会对你有所帮助。
答案 1 :(得分:0)
尝试使用此总计订单项;
$count = 0;
$_order = $this->getOrder();
foreach ($_order->getAllItems() as $items){
$count++
}
echo 'Total lines is '.$count;
或者这是总数量;
$totalqty = 0;
$_order = $this->getOrder();
foreach ($_order->getAllItems() as $items){
$totalqty = $totalqty + $items->getQtyOrdered();
}
echo 'Total qty is '.$totalqty;