Allows calculation of custom discounts.


Input (passed by reference)

$params array Parameters.
$params['order'] array Order data.
$params['contact'] array Customer data.
$params['apply'] bool|null Flag requiring to apply or only to calculate the discount value.
… your plugin code …


float Discount amount expressed in order currency.
string Description of discount applied to entire order.
array Information about discounts applied to individual order items; array keys are order item IDs, their values are sub-arrays with keys 'discount' (discount amount for an order item) and 'description' (item discount description).
float Simple format for returning the discount amount expressed in the order currency instead of an array for 'discount' and 'description' keys. In this case the discount description is generated from the discount plugin name and the applied discount amount.

Plugin code example


public function orderCalculateDiscount($params)
    $discount = shopMyPluginHelper::getDiscount($params);
    return array(
        'discount'    => $discount['amount'],
        'description' => $discount['info'],