Manager
Table of Contents
Methods
- disableExistenceDiscountsWithGift() : void
- Disables existence discount with gift.
- enableExistenceDiscountsWithGift() : void
- Enables existence discount with gift.
- existsDiscountsWithGift() : bool
- Returns true if exists discount with gift.
- getCollectionsByBasket() : array<string|int, mixed>
- Returns list of collections with gifts by basket.
- getCollectionsByProduct() : array<string|int, mixed>|null
- Returns list of collections with gifts by product and some basket.
- getInstance() : Manager
- Returns Singleton of Manager
- getUserId() : int
- isContainGiftAction() : bool
- Returns true if the discount contains action with gift.
- isGift() : bool|null
- Returns true if the product is gift for basket.
- setUserId() : $this
Methods
disableExistenceDiscountsWithGift()
Disables existence discount with gift.
public
disableExistenceDiscountsWithGift() : void
enableExistenceDiscountsWithGift()
Enables existence discount with gift.
public
enableExistenceDiscountsWithGift() : void
existsDiscountsWithGift()
Returns true if exists discount with gift.
public
existsDiscountsWithGift() : bool
Tags
Return values
boolgetCollectionsByBasket()
Returns list of collections with gifts by basket.
public
getCollectionsByBasket(Basket $basket[, array<string|int, mixed>|null $discounts = null ][, array<string|int, mixed>|null $appliedDiscounts = null ]) : array<string|int, mixed>
For performance you may set arguments $discounts and $appliedDiscounts, which respond to basket.
Parameters
- $basket : Basket
-
Target basket.
- $discounts : array<string|int, mixed>|null = null
-
List of all discounts for basket, which already succeed conditions.
- $appliedDiscounts : array<string|int, mixed>|null = null
-
List of all discounts for basket, which already applied to basket.
Return values
array<string|int, mixed>getCollectionsByProduct()
Returns list of collections with gifts by product and some basket.
public
getCollectionsByProduct(Basket $basket, array<string|int, mixed> $product) : array<string|int, mixed>|null
If basket does not contain product, then we calculate gifts without the product. After we add the product to basket, calculate gifts and comparing with previous gifts. If there is difference, then the method returns gifts with the product, else the method returns empty array.
Parameters
- $basket : Basket
-
Target basket.
- $product : array<string|int, mixed>
-
Array which describes product (@see isValidProduct()).
Return values
array<string|int, mixed>|nullgetInstance()
Returns Singleton of Manager
public
static getInstance() : Manager
Return values
ManagergetUserId()
public
getUserId() : int
Return values
intisContainGiftAction()
Returns true if the discount contains action with gift.
public
isContainGiftAction(array<string|int, mixed> $discount) : bool
Parameters
- $discount : array<string|int, mixed>
-
Discount.
Return values
boolisGift()
Returns true if the product is gift for basket.
public
isGift(Basket $basket, array<string|int, mixed> $product) : bool|null
Parameters
- $basket : Basket
-
Target basket.
- $product : array<string|int, mixed>
-
Array which describes product (@see isValidProduct()).
Return values
bool|nullsetUserId()
public
setUserId(int $userId) : $this
Parameters
- $userId : int