-
Notifications
You must be signed in to change notification settings - Fork 215
Description
in my dokan site after i issue a partial refund to a buyer, the vendors earnings don't update to reflect the new total. as a result i get a stripe error when the order completes and stripe tries to disburse the funds as stripe is trying to transfer the original vendor earnings amount before the partial refund and it is obviosuly not able to pull that much money from the transaction since the order total has gone down after the refund.
that's why i'm trying to manipulate the vendor earnings before they are transferred. i tried using this hook dokan_get_earning_from_order_table and i traced it and it works up until the order hits completed status, then it ignored the filter override i did and grabs the old vendor earning amount. why is it not taking my filter override amount when the order status is completed and the transfer is about to happen?
/**
* Hooks to modify the earning from order table.
*
* @since 4.0.2
*
* @param float|array $earning The earning amount or raw data.
* @param int $order_id The order ID.
* @param string $context The context (admin or seller).
* @param bool $raw Whether to return raw data or not.
*/
return apply_filters(
'dokan_get_earning_from_order_table',
$raw ? $raw_earning : $earning,
$order_id,
$context,
$raw
);
add_filter( 'dokan_get_earning_from_order_table', 'rmd_force_table_raw_earning', 999, 4 );
function rmd_force_table_raw_earning( $earning, $order_id, $context, $raw ) {
return [
'net_amount' => 12.00,
'order_total' => 25.00,
];
}