It's used for cart rules with partial use. When you call function getContextualValue()
from CartRule
class with CartRule::FILTER_ACTION_ALL_NOCAP
filter, it returns the total cart rule amount, not only the amount that should be applied in the current cart (amount can never be higher than products amount):
// The reduction cannot exceed the products total, except when we do not want it to be limited (for the partial use calculation)
if ($filter != CartRule::FILTER_ACTION_ALL_NOCAP) {
$reduction_amount = min($reduction_amount, $this->reduction_tax ? $cart_amount_ti : $cart_amount_te);
}
When the order is validated, the cart rule value is retrieved:
$values = array(
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
);
And a new cart rule is generated if necessary.