order_calculate_discount
Allows calculation of custom discounts.
Shop-Script
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.
$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 …
Output
$return['discount']
float Discount amount expressed in order currency.
$return['description']
string Description of discount applied to entire order.
$return['items']
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).
$return
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.
Shop-Script
Plugin code example
PHP
public function orderCalculateDiscount($params)
{
$discount = shopMyPluginHelper::getDiscount($params);
return [
'discount' => $discount['amount'],
'description' => $discount['info'],
];
}









