BasketReservationHistoryService
Service for working with the history of basket reserves
Table of Contents
Methods
- __construct() : mixed
- add() : Result
- Add history row
- addByReservation() : Result
- Add history row by reservation
- delete() : Result
- Delete history row
- deleteByReservation() : Result
- Delete history rows by reservation.
- getAvailableCountForBasketItem() : float
- The available amount to be debited based on the reservation history.
- getAvailableCountForBasketItems() : array<string|int, mixed>
- The available amount to be debited based on the reservation history.
- getAvailableCountForOrder() : array<string|int, mixed>
- The available amount to be debited based on the reservation history.
- getQuantityByReservation() : float
- Total reserved quantity by reservation history
- update() : Result
- Update history row
- updateByReservation() : Result
- Update history row by reservation
Methods
__construct()
public
__construct() : mixed
add()
Add history row
public
add(array<string|int, mixed> $fields) : Result
Parameters
- $fields : array<string|int, mixed>
Return values
ResultaddByReservation()
Add history row by reservation
public
addByReservation(int $reservationId) : Result
Parameters
- $reservationId : int
Return values
Resultdelete()
Delete history row
public
delete(int $id) : Result
Parameters
- $id : int
Return values
ResultdeleteByReservation()
Delete history rows by reservation.
public
deleteByReservation(int $reservationId) : Result
All related rows will be deleted!
Parameters
- $reservationId : int
Return values
ResultgetAvailableCountForBasketItem()
The available amount to be debited based on the reservation history.
public
getAvailableCountForBasketItem(int $basketId, int $storeId) : float
Example 1, there are 100pcs of product A in stock, then:
- Deal #1 - 80pcs reserved;
- Deal #2 - 40pcs reserved;
- Deal #1 - the reserve has been changed from 80pcs to 90pcs - in this situation, another record with a reserve of 10pcs is added to the history.
Thus, deal #1 can write off only 80pcs (because 10pcs were reserved after deal #2), and deal #2 only 20pcs (because they were reserved after deal #1).
Example 2, there are 100pcs of product A in stock, then:
- Deal #1 - 40pcs reserved;
- Deal #2 - 50pcs reserved;
Thus, deal #1 can write off 50pcs (40 reserved + 10 non-reserved store balance), and deal #2 60pcs (50 reserved + 10 non-reserved store balance).
Parameters
- $basketId : int
- $storeId : int
Return values
float —avaiable quantity
getAvailableCountForBasketItems()
The available amount to be debited based on the reservation history.
public
getAvailableCountForBasketItems(array<string|int, mixed> $basketItemFilter) : array<string|int, mixed>
Parameters
- $basketItemFilter : array<string|int, mixed>
-
filter for
BasketTable
tablet.
Tags
Return values
array<string|int, mixed> —in format $ret[$productId][$storeId]; // avaiableQuantity
getAvailableCountForOrder()
The available amount to be debited based on the reservation history.
public
getAvailableCountForOrder(int $orderId) : array<string|int, mixed>
Parameters
- $orderId : int
Tags
Return values
array<string|int, mixed> —in format $ret[$productId][$storeId]; // avaiableQuantity
getQuantityByReservation()
Total reserved quantity by reservation history
public
getQuantityByReservation(int $reservationId) : float
Parameters
- $reservationId : int
Return values
floatupdate()
Update history row
public
update(int $id, array<string|int, mixed> $fields) : Result
Parameters
- $id : int
- $fields : array<string|int, mixed>
Return values
ResultupdateByReservation()
Update history row by reservation
public
updateByReservation(int $reservationId) : Result
Parameters
- $reservationId : int