public function matches(CartItem $cartItem) { if ($cartItem->getProduct()->getId() == $this->product->getId() and $cartItem->getQuantity() >= $this->quantity) { return true; } return false; }
public function matches(CartItem $cartItem) { foreach ($cartItem->getProduct()->getTags() as $tag) { if ($tag->getId() === $this->tag->getId() and $cartItem->getQuantity() >= $this->quantity) { return true; } } return false; }
public function testCreateDefaults() { $cartItem = new CartItem(); $this->assertSame(null, $cartItem->getQuantity()); $this->assertSame(null, $cartItem->getProduct()); $this->assertSame(null, $cartItem->getCart()); $this->assertSame(0, count($cartItem->getCartItemOptionProducts())); $this->assertSame(0, count($cartItem->getCartItemOptionValues())); $this->assertSame(0, count($cartItem->getCartItemTextOptionValues())); $this->assertSame(0, count($cartItem->getAttachments())); }
/** * @return static */ public function withProduct(Pricing $pricing) { $this->entityDTO->product = $this->dtoBuilderFactory->getProductDTOBuilder($this->entity->getProduct())->withTags()->withProductQuantityDiscounts($pricing)->build(); return $this; }