Option
in package
Uses
ElementTrait, IdentifiableElementTrait, IntegrableElementTrait, EnumResolverTrait
This is the Option class.
The options information of API products will be stored in that class and will remain immutable (only get methods are available)
Tags
Table of Contents
$id | Autonumeric element id. | : int |
---|---|---|
$pId | Public and readable element id. | : string |
__construct() | Elements constructor. | : mixed |
__toString() | Uses "json_encode" function to return the JSON format of the element. | : string |
getCombinable() | Sets if the option is combinable or not. | : bool |
getFilterable() | Sets if the option is filterable or not. | : bool |
getId() | Returns the element id. | : int |
getImage() | Returns the option image. | : string |
getLanguage() | Returns the option language object. | : OptionLanguage|null |
getMaxValues() | Returns the maximum value of this option. | : int |
getMinValues() | Returns the minimum value of this option. | : int |
getPId() | Returns the element public id (pId). | : string |
getPriority() | Returns the option priority. | : int |
getRequired() | Sets if the option is required or not. | : bool |
getShowAsGrid() | Sets if the option has to be displayed on a grid or not. | : bool |
getType() | Returns the option type. | : string |
getTypology() | Returns the option typology. | : string |
getUniquePrice() | Sets if the option price increment must be added to the base product price only for the first unit added to the cart or for every one of them. | : bool |
getValues() | Returns the collection of values for this option. | : array<string|int, OptionValue> |
jsonSerialize() | Allow elements to be serialized. | : array<string|int, mixed> |
toArray() | Used to allow elements to be serialized. | : array<string|int, mixed> |
getFieldItem() | : object|null | |
getFormattedData() | : mixed | |
setArrayField() | Convert an API array of objects to a PHP array of objects. | : array<string|int, mixed> |
Properties
$id
Autonumeric element id.
protected
int
$id
= 0
All the given elements by the LogiCommerce API will send it.
$pId
Public and readable element id.
protected
string
$pId
= ''
Setted by the user on LogiCommerce. All the integrable elements by the LogiCommerce API will send it. Useful for integrations and other 3rd party softwares that need to connect to LogiCommerce software.
Methods
__construct()
Elements constructor.
public
__construct([array<string|int, mixed> $data = [] ]) : mixed
Parameters
- $data : array<string|int, mixed> = []
-
Array that contains all the values to the object to initialize
Return values
mixed —__toString()
Uses "json_encode" function to return the JSON format of the element.
public
__toString() : string
Auto-invoked using echo or concatenations.
Return values
string —getCombinable()
Sets if the option is combinable or not.
public
getCombinable() : bool
Return values
bool —getFilterable()
Sets if the option is filterable or not.
public
getFilterable() : bool
Return values
bool —getId()
Returns the element id.
public
getId() : int
Return values
int —getImage()
Returns the option image.
public
getImage() : string
Return values
string —getLanguage()
Returns the option language object.
public
getLanguage() : OptionLanguage|null
Tags
Return values
OptionLanguage|null —getMaxValues()
Returns the maximum value of this option.
public
getMaxValues() : int
Return values
int —getMinValues()
Returns the minimum value of this option.
public
getMinValues() : int
Return values
int —getPId()
Returns the element public id (pId).
public
getPId() : string
Return values
string —getPriority()
Returns the option priority.
public
getPriority() : int
.
Return values
int —getRequired()
Sets if the option is required or not.
public
getRequired() : bool
Return values
bool —getShowAsGrid()
Sets if the option has to be displayed on a grid or not.
public
getShowAsGrid() : bool
Return values
bool —getType()
Returns the option type.
public
getType() : string
Return values
string —getTypology()
Returns the option typology.
public
getTypology() : string
This value is normally used for google shopping feeds or other 3rd party outputs that need it.
Return values
string —getUniquePrice()
Sets if the option price increment must be added to the base product price only for the first unit added to the cart or for every one of them.
public
getUniquePrice() : bool
Return values
bool —getValues()
Returns the collection of values for this option.
public
getValues() : array<string|int, OptionValue>
Tags
Return values
array<string|int, OptionValue> —jsonSerialize()
Allow elements to be serialized.
public
jsonSerialize() : array<string|int, mixed>
Auto-invoked using "json_encode" function.
Return values
array<string|int, mixed> —toArray()
Used to allow elements to be serialized.
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —getFieldItem()
protected
getFieldItem(array<string|int, mixed> $item, string $class) : object|null
Parameters
- $item : array<string|int, mixed>
- $class : string
Return values
object|null —getFormattedData()
protected
getFormattedData(mixed $value) : mixed
Parameters
- $value : mixed
Return values
mixed —setArrayField()
Convert an API array of objects to a PHP array of objects.
protected
setArrayField(array<string|int, mixed> $data, string $class) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
-
Array that contains all the values to the objects to initialize
- $class : string
-
The PHP class we want the objects to be