Replies: 0
Hi,
Is there any way to limit the usage of wallet balance same as in the cashback? It will be great if admin can set a maximum usable amount or percentage of the wallet balance in checkout. For example, if a customer have 100 usd in wallet and he purchases a product for 200 usd, and admin have an option to limit maximum 20% of cart value to deduct, then the user can deduct only 40 usd from wallet and rest can be paid from gateway, instead of paying the entire 100 from wallet.
I used one code given up on woo wallet support page which is
add_filter(‘is_valid_payment_through_wallet’, ‘__return_false’);
add_filter(‘woo_wallet_partial_payment_amount’, ‘woo_wallet_partial_payment_amount_callback’, 10, 2);
function woo_wallet_partial_payment_amount_callback($amount, $order) {
if (!is_null($order)) {
$order_total = $order->get_total(‘edit’);
if ($amount > $order_total) {
$amount = ($order_total * 20) / 100;
}
} else if (sizeof(wc()->cart->get_cart()) > 0) {
$cart_total = wc()->cart->get_total(‘edit’);
if ($amount > $cart_total) {
$amount = ($cart_total * 20) / 100;
}
}
return $amount;
}
I changed name of woo to tera and everything remained same but it is not actually working. It’s showing incorrect amount and actually the charge which is getting deducted from payment gateway is same as the price of product. Please send me an updated code. It would be really helpful.
Thanks and Regards!