@teacherbahrami You can customise cashback calculation using filter woo_wallet_form_cart_cashback_amount.
Thank you,
Could you tell me how to use this filter?
I appreciate if you help me out with this
@subratamal I appreciate if you help me out with this
@teacherbahrami Please reach out to us at our support email support@woowallet.in regarding this topic.
Thanks
Hi,
I love the plugin but I also need a solution to this, would appreciate if you could share any resolution for this.
Basically I need the following calculation for cashback:
cashback amount =
[ cost of product (inc tax) – any discounts – shipping cost – wallet credit ] * cashback %
Could you help? Thanks so much!
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;
}