lukepolo / laracart

Laravel Shopping Cart Package
https://laracart.lukepolo.com
MIT License
576 stars 86 forks source link

setting a discount for each item in the cart #301

Closed Augen2203 closed 3 years ago

Augen2203 commented 3 years ago

Can I add a discount separately, for each product added to the cart?

For example like this:$cart->setDiscount($cartItem->itemHash, $product->Discount)

For example, I have a product that now has a 10% discount.

In the general field there is a discount.

Also, display a discount for each item in the basket (both a discount for the product itself and a discount with the applied coupon).

Thanks to.

lukepolo commented 3 years ago

You can add a coupon for each item , and for the entire cart.

Whole Cart

 $fixedCoupon = new LukePOLO\LaraCart\Coupons\Fixed('500 OFF', 500);
LaraCart::addCoupon($fixedCoupon);

Per Item

 $fixedCoupon = new LukePOLO\LaraCart\Coupons\Fixed('10OFF', 10);
 $fixedCoupon->setDiscountOnItem($item);