本文整理匯總了PHP中Sylius\Component\Core\Model\OrderInterface::countItems方法的典型用法代碼示例。如果您正苦於以下問題:PHP OrderInterface::countItems方法的具體用法?PHP OrderInterface::countItems怎麽用?PHP OrderInterface::countItems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sylius\Component\Core\Model\OrderInterface
的用法示例。
在下文中一共展示了OrderInterface::countItems方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: apply
/**
* {@inheritdoc}
*/
public function apply(OrderInterface $order, PromotionInterface $promotion, array $adjustmentsAmounts)
{
Assert::eq($order->countItems(), count($adjustmentsAmounts));
$i = 0;
foreach ($order->getItems() as $item) {
$adjustmentAmount = $adjustmentsAmounts[$i++];
if (0 === $adjustmentAmount) {
continue;
}
$this->applyAdjustmentsOnItemUnits($item, $promotion, $adjustmentAmount);
}
}
示例2:
function it_throws_exception_if_items_count_is_different_than_adjustment_amounts(PromotionInterface $promotion, OrderInterface $order)
{
$order->countItems()->willReturn(2);
$this->shouldThrow(\InvalidArgumentException::class)->during('apply', [$order, $promotion, [1999]]);
}
示例3:
function it_does_not_revert_if_order_has_no_items(OrderInterface $order, PromotionInterface $promotion)
{
$order->countItems()->willReturn(0);
$order->getItems()->shouldNotBeCalled();
$this->revert($order, [], $promotion);
}