Also I want it to not give cashback on the shipping payment. For that I used this code which worked perfectly as it gets the amount from the subtotal. The problem is that the discounted amount is after credits are aplied. Any way to eliminate cashback from shipping and when customer pays with credits?
if (!function_exists(‘woo_wallet_form_cart_cashback_amount_callback’)) {
function woo_wallet_form_cart_cashback_amount_callback($cashback_amount) {
$cashback_rule = woo_wallet()->settings_api->get_option(‘cashback_rule’, ‘_wallet_settings_credit’, ‘cart’);
$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));
$max_cashbak_amount = floatval(woo_wallet()->settings_api->get_option(‘max_cashback_amount’, ‘_wallet_settings_credit’, 0));
if (‘cart’ === $cashback_rule) {
if (‘percent’ === $global_cashbak_type) {
$percent_cashback_amount = wc()->cart->get_subtotal(‘edit’) * ( $global_cashbak_amount / 100 );
if ($max_cashbak_amount && $percent_cashback_amount > $max_cashbak_amount) {
$cashback_amount = $max_cashbak_amount;
} else {
$cashback_amount = $percent_cashback_amount;
}
} else {
$cashback_amount = $global_cashbak_amount;
}
}
return $cashback_amount;
}
}