affiliate_transaction
Triggered upon changes in the customer affiliate points balance as a result of newly placed or paid orders, or administrator’s actions in the customer profile.
Available since version 11.3.0.
Shop-Script
Input (passed by reference)
$params['type'] string Type of operation performed on affiliate points: 'deposit' (increase caused by administrator’s actions in the customer profile), 'withdrawal' (decrease caused by administrator’s actions in the customer profile), 'order_bonus' (accrual for a paid order), 'order_discount' (deduction for a new order with applied points), 'order_cancel' (deduction because of the refund of a paid order).
$params['id'] int Points operation ID.
$params['contact_id'] int Customer ID.
$params['amount'] float Amount of points added to, or deducted from, the customer account.
$params['order_id'] int Order ID.
$params['comment'] string Localized description of the operation on points.
$params['balance'] float Amount of points available on the customer account after the operation completion.
$params['log_id'] int|null ID of an order action related to the operation on points.
$params['order'] array|null Information about an order (if the operation on points was caused by an order-related action).
$params['id'] int Points operation ID.
$params['contact_id'] int Customer ID.
$params['amount'] float Amount of points added to, or deducted from, the customer account.
$params['order_id'] int Order ID.
$params['comment'] string Localized description of the operation on points.
$params['balance'] float Amount of points available on the customer account after the operation completion.
$params['log_id'] int|null ID of an order action related to the operation on points.
$params['order'] array|null Information about an order (if the operation on points was caused by an order-related action).
… your plugin code …
Output
Shop-Script
Plugin code example
PHP
public function affiliateTransaction($params)
{
switch ($params['type']) {
case shopAffiliateTransactionModel::TYPE_DEPOSIT:
case shopAffiliateTransactionModel::TYPE_ORDER_BONUS:
$message = sprintf_wp(
'The amount of %0.4f has been added to the account of customer with id=%d.',
$params['amount'],
$params['contact_id']
);
break;
case shopAffiliateTransactionModel::TYPE_ORDER_CANCEL:
case shopAffiliateTransactionModel::TYPE_ORDER_DISCOUNT:
case shopAffiliateTransactionModel::TYPE_WITHDRAWAL:
$message = sprintf_wp(
'The amount of %0.4f has been deducted from the account of customer with id=%d.',
$params['amount'],
$params['contact_id']
);
break;
}
waLog::log(
$message,
'shop/plugins/' . $this->id . '/affiliate_transaction.log'
);
}









