• Resolved ehoty

    (@ehoty)


    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 5000 usd in wallet and he purchases a product for 10 usd, and admin have an option to limit maximum 20% of wallet amount to deduct,then the user can deduct only 10 usd from wallet because the limit of maximum amount is bigger than his ordered amount, instead of paying the entire 5000 from wallet.
    Is it possible?

    Thanks in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ehoty

    (@ehoty)

    I already use this code but the problem is when the maximum amount of debit amount is bigger than the cart price, it won’t work. Ex: The product price is $10 but customer have $5000 in wallet.I limit the 20% of amount to deduct from wallet, Then it shows $1000 deducated from wallet but the product price is only $10.
    For better understanding see the screenshot. Image: https://ibb.co/FJPNTp2
    Please help me.

    add_filter(‘is_valid_payment_through_wallet’, ‘__return_false’);
    add_filter(‘woo_wallet_partial_payment_amount’, ‘woo_wallet_partial_payment_amount_callback’);
    function woo_wallet_partial_payment_amount_callback($amount){
    return (woo_wallet()->wallet->get_wallet_balance( get_current_user_id(), ‘edit’ ) * 20) / 100;
    }

    Thread Starter ehoty

    (@ehoty)

    Finally, I found a code that works for me perfectly. But Some change needed. Can anyone change the code, please? In this code the 20% debited amount calculate from the total cart amount, but I want the 20% debited amount calculated from the total wallet amount.

    add_filter(‘is_valid_payment_through_wallet’, ‘__return_false’);
    add_filter(‘woo_wallet_partial_payment_amount’, ‘woo_wallet_partial_payment_amount_callback’, 10);

    function woo_wallet_partial_payment_amount_callback($amount) {
    if (sizeof(wc()->cart->get_cart()) > 0) {
    $cart_total = get_woowallet_cart_total();
    $partial_payment_amount = ($cart_total * 20) / 100;
    if ($amount >= $partial_payment_amount) {
    $amount = $partial_payment_amount;
    }
    }
    return $amount;
    }

    VENAXIS

    (@venaxis)

    Actually this is an important addition if it can be added to the plugin’s settings. Like allowing only up to 50% of the item’s value to be paid in wallet credits.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to limit Woocommerce wallet setting?’ is closed to new replies.