ItemComparator extends AbstractItemComparator
Item Comparator for MetaItemPrices
Table of Contents
Properties
| $description_callback | |
| $price_callback |
Methods
| __construct() | Initializes a set of callbacks |
| merge() | {@inheritdoc} |
| setDescriptionCallback() | Sets the pricing callback that expects two arguments: |
| setPriceCallback() | Sets the pricing callback that expects four arguments: |
| price() | Retrieves the combined price of the given items |
Methods
__construct()
Initializes a set of callbacks
public
__construct(callable $price_callback, callable $description_callback) : mixed
Parameters
- $price_callback : callable
-
The pricing callback that accepts four arguments for the old and new price, and the old and new ItemPrice meta data (each a Blesta\Items\Item\ItemCollection), and returns a float
- $description_callback : callable
-
The description callback that accepts two arguments for the old and new ItemPrice meta data (each a Blesta\Items\Item\ItemCollection or null), and returns a string
merge()
{@inheritdoc}
public
merge(ItemPrice $item1, ItemPrice $item2) : mixed
Parameters
- $item1 : ItemPrice
- $item2 : ItemPrice
setDescriptionCallback()
Sets the pricing callback that expects two arguments:
public
setDescriptionCallback(callable $callback) : mixed
- a Blesta\Items\Collection\ItemCollection of the old ItemPrice meta data, or null
- a Blesta\Items\Collection\ItemCollection of the new ItemPrice meta data, or null and returns a string representing a description.
Parameters
- $callback : callable
-
The callback
setPriceCallback()
Sets the pricing callback that expects four arguments:
public
setPriceCallback(callable $callback) : mixed
- the old price as a float
- the new price as a float
- a Blesta\Items\Collection\ItemCollection of the old ItemPrice meta data, or null
- a Blesta\Items\Collection\ItemCollection of the new ItemPrice meta data, or null and returns a float value representing a price.
Parameters
- $callback : callable
-
The callback
price()
Retrieves the combined price of the given items
private
price(ItemPrice $item1, ItemPrice $item2) : float
Parameters
- $item1 : ItemPrice
-
The from item
- $item2 : ItemPrice
-
The to item
Return values
float —The combined price