class DiscountManager implements DiscountManagerInterface (View source)

Properties

protected null|Channel> $channels

The current channels.

protected null|CustomerGroup> $customerGroups

The current customer groups

protected $discounts

The available discounts

protected array $types

The available discount types

protected $applied

The applied discounts.

Methods

__construct()

Instantiate the class.

channel(Channel|iterable $channel)

Set a single channel or a collection.

customerGroup(CustomerGroup|iterable $customerGroups)

Set a single customer group or a collection.

Collection
getChannels()

Return the applied channels.

Collection
getDiscounts(Cart $cart = null)

Returns the available discounts.

Collection
getCustomerGroups()

Return the applied customer groups.

addType(string $classname)

Add a discount type by classname

Collection
getTypes()

Return the available discount types.

addApplied(CartDiscount $cartDiscount)

Add an applied discount

Collection
getApplied()

Return the applied discounts

apply(Cart $cart)

Apply discounts for a given cart.

bool
validateCoupon(string $coupon)

Validate a given coupon against all system discounts.

Details

__construct()

Instantiate the class.

DiscountManager channel(Channel|iterable $channel)

Set a single channel or a collection.

Parameters

Channel|iterable $channel

Return Value

DiscountManager

DiscountManager customerGroup(CustomerGroup|iterable $customerGroups)

Set a single customer group or a collection.

Parameters

CustomerGroup|iterable $customerGroups

Return Value

DiscountManager

Collection getChannels()

Return the applied channels.

Return Value

Collection

Collection getDiscounts(Cart $cart = null)

Returns the available discounts.

Parameters

Cart $cart

Return Value

Collection

Collection getCustomerGroups()

Return the applied customer groups.

Return Value

Collection

DiscountManagerInterface addType(string $classname)

Add a discount type by classname

Parameters

string $classname

Return Value

DiscountManagerInterface

Collection getTypes()

Return the available discount types.

Return Value

Collection

DiscountManagerInterface addApplied(CartDiscount $cartDiscount)

Add an applied discount

Parameters

CartDiscount $cartDiscount

Return Value

DiscountManagerInterface

Collection getApplied()

Return the applied discounts

Return Value

Collection

Cart apply(Cart $cart)

Apply discounts for a given cart.

Parameters

Cart $cart

Return Value

Cart

bool validateCoupon(string $coupon)

Validate a given coupon against all system discounts.

Parameters

string $coupon

Return Value

bool