marcryu
Forum Replies Created
-
Forum: Plugins
In reply to: [Wallet for WooCommerce] Calculate Cashback only after Coupon DiscountHi Subrata,
Thanks for the quick response.
I’d added the above snippet as follows:
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; } add_filter('woo_wallet_calculate_cashback_on_total', '__return_false');However, the cashback was still calculated without taking the discount coupon amount into consideration.
Did I enter the filter wrongly?
Regards
MarcForum: Plugins
In reply to: [Wallet for WooCommerce] Calculate Cashback only after Coupon DiscountThis is the snippet you provided in the past to adjust cashback based on actual amount paid. It works fine in general.
However, when a coupon is used, the cashback doesn’t take into consideration the coupon discount.
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;
}I have this snippet which you’d helped me with previously to adjust the cashback calculation. Could this be the reason for it not working when switching to product/category-wise?
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;
}Forum: Plugins
In reply to: [Wallet for WooCommerce] Cashback on bank gatewayHi, 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;
}Forum: Plugins
In reply to: [Wallet for WooCommerce] Cashback on bank gatewayHi,
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!