mirror of
https://github.com/wearepixel/laravel-cart.git
synced 2026-11-14 13:51:44 +00:00
feat: add Cart::coupon(), Cart::tax(), Cart::shipping()
Proxy methods that accept first-class Coupon, TaxRule, and ShippingRate objects and delegate to Cart::condition() via toCondition().
This commit is contained in:
@@ -5,7 +5,10 @@
|
||||
namespace Wearepixel\Cart;
|
||||
|
||||
use Closure;
|
||||
use Wearepixel\Cart\Coupons\Coupon;
|
||||
use Wearepixel\Cart\Helpers\Helpers;
|
||||
use Wearepixel\Cart\Shipping\ShippingRate;
|
||||
use Wearepixel\Cart\Tax\TaxRule;
|
||||
use Wearepixel\Cart\Validators\CartItemValidator;
|
||||
use Wearepixel\Cart\Exceptions\InvalidItemException;
|
||||
use Wearepixel\Cart\Exceptions\UnknownModelException;
|
||||
@@ -276,6 +279,21 @@ public function condition(array|CartCondition $condition): self
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function coupon(Coupon $coupon): self
|
||||
{
|
||||
return $this->condition($coupon->toCondition());
|
||||
}
|
||||
|
||||
public function tax(TaxRule $taxRule): self
|
||||
{
|
||||
return $this->condition($taxRule->toCondition());
|
||||
}
|
||||
|
||||
public function shipping(ShippingRate $shippingRate): self
|
||||
{
|
||||
return $this->condition($shippingRate->toCondition());
|
||||
}
|
||||
|
||||
public function getConditions(bool $array = false, bool $active = false): CartConditionCollection|array
|
||||
{
|
||||
$conditions = new CartConditionCollection($this->driver->getConditions());
|
||||
|
||||
Reference in New Issue
Block a user