abstract class CartCondition implements Arrayable, Jsonable, Serializable

CartCondition class

Traits

Properties

protected Collection $actionCollection from  CartConditionHelper
string $name

The name for this cart condition.

int|float $label

The label for this cart condition.

int $priority

The priority for this cart condition.

$removeable
protected $sessionKey
protected $cartInstance
protected CartContent|CartItem $target
protected $passed
protected $calculatedValue
protected array $config

The config for this cart condition.

Methods

validate($rules)

No description

float|string
processValue($subTotal)

Added for backward compatibility

processActionValue($action, $total)

No description

calculateActionValue($action, $total)

No description

actionHasReachedMax($actionMax, $value)

No description

mixed
cleanValue($value)

Removes some arithmetic signs (%,+,-, /, *) only

operandValue($key)

No description

ruleIsValid($rule)

No description

parseRule($rule)

No description

parseAction($action)

No description

actionIsInclusive($action)

No description

bool
valueIsPercentage($value)

Check if value is a percentage

bool
valueIsToBeSubtracted($value)

Check if value is a subtract

bool
valueIsToBeAdded($value)

Check if value is to be added

bool
valueIsToBeMultiplied($value)

Check if value is to be added

bool
valueIsToBeDivided($value)

Check if value is to be added

getSessionKey()

No description

__construct(array $config = [])

CartItem constructor.

fillFromConfig($config)

No description

isValid()

No description

isApplied()

No description

isInclusive()

No description

float|string
apply($subTotal)

Apply condition to cart content

float|string
calculate($subTotal)

Get the calculated the value of this condition Used internally when applying to cart item

onLoad()

Called before condition is loaded into cart session

beforeApply()

Called before the applying of condition on the entire cart.

afterApply()

Called after the applying of condition on the entire cart.

array
getRules()

Returns the rules for this cart condition.

array
getActions()

Returns the actions for this cart condition.

whenValid()

Called once when the condition validation passes.

whenInvalid()

Called once when the condition validation fails.

withTarget($target)

No description

setCartContent($cartContent)

No description

getCartContent()

No description

getLabel()

No description

getValue()

No description

getPriority()

No description

setPriority(int $priority = 999)

Set the order in which this condition is applied.

getConfig($key, $default = null)

No description

setConfig($key, $value)

No description

getMetaData($key = null, $default = null)

No description

setMetaData($key, $value = null)

No description

removeMetaData($key = null)

No description

clearMetaData()

No description

array
toArray()

Get the instance as an array.

string
toJson(int $options = 0)

Convert the object to its JSON representation.

serialize()

String representation of object

void
unserialize(string $serialized)

Constructs the object

Details

protected validate($rules)

No description

Parameters

$rules

protected float|string processValue($subTotal)

Added for backward compatibility

Parameters

$subTotal

Return Value

float|string

protected processActionValue($action, $total)

No description

Parameters

$action
$total

protected calculateActionValue($action, $total)

No description

Parameters

$action
$total

protected actionHasReachedMax($actionMax, $value)

No description

Parameters

$actionMax
$value

in CartConditionHelper at line 109
protected mixed cleanValue($value)

Removes some arithmetic signs (%,+,-, /, *) only

Parameters

$value

Return Value

mixed

in CartConditionHelper at line 114
protected operandValue($key)

No description

Parameters

$key

in CartConditionHelper at line 125
protected ruleIsValid($rule)

No description

Parameters

$rule

in CartConditionHelper at line 151
protected parseRule($rule)

No description

Parameters

$rule

in CartConditionHelper at line 163
protected parseAction($action)

No description

Parameters

$action

in CartConditionHelper at line 174
protected actionIsInclusive($action)

No description

Parameters

$action

in CartConditionHelper at line 186
protected bool valueIsPercentage($value)

Check if value is a percentage

Parameters

$value

Return Value

bool

in CartConditionHelper at line 198
protected bool valueIsToBeSubtracted($value)

Check if value is a subtract

Parameters

$value

Return Value

bool

in CartConditionHelper at line 210
protected bool valueIsToBeAdded($value)

Check if value is to be added

Parameters

$value

Return Value

bool

in CartConditionHelper at line 222
protected bool valueIsToBeMultiplied($value)

Check if value is to be added

Parameters

$value

Return Value

bool

in CartConditionHelper at line 234
protected bool valueIsToBeDivided($value)

Check if value is to be added

Parameters

$value

Return Value

bool

in CartConditionHelper at line 243
protected getSessionKey()

No description

at line 75
__construct(array $config = [])

CartItem constructor.

Parameters

array $config

at line 81
fillFromConfig($config)

No description

Parameters

$config

at line 93
isValid()

No description

at line 98
isApplied()

No description

at line 103
isInclusive()

No description

at line 119
float|string apply($subTotal)

Apply condition to cart content

Parameters

$subTotal

Return Value

float|string

at line 140
float|string calculate($subTotal)

Get the calculated the value of this condition Used internally when applying to cart item

Parameters

$subTotal

Return Value

float|string

at line 160
onLoad()

Called before condition is loaded into cart session

at line 167
beforeApply()

Called before the applying of condition on the entire cart.

at line 174
afterApply()

Called after the applying of condition on the entire cart.

at line 183
array getRules()

Returns the rules for this cart condition.

Return Value

array

at line 193
array getActions()

Returns the actions for this cart condition.

Return Value

array

at line 201
whenValid()

Called once when the condition validation passes.

at line 208
whenInvalid()

Called once when the condition validation fails.

at line 216
withTarget($target)

No description

Parameters

$target

at line 223
setCartContent($cartContent)

No description

Parameters

$cartContent

at line 230
getCartContent()

No description

at line 237
getLabel()

No description

at line 242
getValue()

No description

at line 247
getPriority()

No description

at line 257
setPriority(int $priority = 999)

Set the order in which this condition is applied.

Parameters

int $priority

at line 262
protected getConfig($key, $default = null)

No description

Parameters

$key
$default

at line 267
protected setConfig($key, $value)

No description

Parameters

$key
$value

at line 272
getMetaData($key = null, $default = null)

No description

Parameters

$key
$default

at line 281
setMetaData($key, $value = null)

No description

Parameters

$key
$value

at line 297
removeMetaData($key = null)

No description

Parameters

$key

at line 311
clearMetaData()

No description

at line 325
array toArray()

Get the instance as an array.

Return Value

array

at line 343
string toJson(int $options = 0)

Convert the object to its JSON representation.

Parameters

int $options

Return Value

string

at line 351
serialize()

String representation of object

at line 363
void unserialize(string $serialized)

Constructs the object

Parameters

string $serialized

Return Value

void