Hi, Ignore my previous request. I’ve already got a working solution. Just ensure you have CODE SNIPPETS plugin installed so you can add the code into the function.php without touching the original.
Create a new snippet and paste the following code and activate.
This calculates:
? Amount of purchase including taxes and discounts
? Minus any Wallet balance (when the setting for using wallet amount to offset purchase is set)
? also excludes Shipping fees being calculated for a cashback
——————————
add_filter(‘woo_wallet_form_cart_cashback_amount’, ‘woo_wallet_form_cart_cashback_amount_callback’, 10);
function woo_wallet_form_cart_cashback_amount_callback($cashback_amount) {
$global_cashbak_type = woo_wallet()->settings_api->get_option(‘cashback_type’, ‘_wallet_settings_credit’, ‘percent’);
$global_cashbak_amount = floatval(woo_wallet()->settings_api->get_option(‘cashback_amount’, ‘_wallet_settings_credit’, 0));
$global_wallet_balance = woo_wallet()->wallet->get_wallet_balance( get_current_user_id(), ‘edit’ );
if (‘percent’ === $global_cashbak_type) {
$cashback_amount = $cashback_amount = (wc()->cart->get_subtotal() + wc()->cart->get_subtotal_tax()- $global_wallet_balance) * ($global_cashbak_amount / 100);
}
return $cashback_amount;
}