• Resolved danielferreiraneto

    (@danielferreiraneto)


    Hello,

    I’m requesting your help regarding the maximum wallet amount used by an user.
    I want the wallet to be capped at a cart total percentage.

    I’ve read somewhere else that it is possible, but requires some coding, I don’t mind, I just can’t seem to find my way around the plugin files, in order to program it as I want to, so any help would be immensely appreciated!

    Further explanation:
    In a 1000€ cart, allow only the user to pay up to 600€ with it’s wallet, and the rest with an external payment method (paypal, bank transfer, etc).
    Cap it to 60%, no matter the product, the cart total or user group/privileges, if needed I don’t mind hard-coding it onto the script, I really don’t.

    I’ve seen great advancements with the plugin in the last months, this is just what I’m missing, everything else is intuitive and well structured/thought.

    An advanced appreciation for your help.
    And keep up the good work.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Subrata Mal

    (@subratamal)

    @danielferreiraneto,

    Thanks for reaching out to our support forum. I understand your requirement but it is a tricky one. Please use bellow code snippet to themes function.php file.

    add_action('wp_loaded', 'filter_woo_wallet_balance');
    
    function filter_woo_wallet_balance(){
        if(sizeof(wc()->cart->get_cart()) > 0 && !is_wallet_rechargeable_cart()){
            add_filter('woo_wallet_current_balance', 'woo_wallet_current_balance');
        }
    }
    
    function woo_wallet_current_balance($balance){
        $cart_total = wc()->cart->get_total('edit');
        if($balance > $cart_total){
            $balance = ($cart_total * 60) / 100;
        }
        return $balance;
    }

    Thanks and Regards,
    Subrata Mal

    Thread Starter danielferreiraneto

    (@danielferreiraneto)

    Hi Subrata,

    Thanks for the reply!

    Where exactly should I insert that code snippet?
    I’m inserting it on:
    wp-content/themes/themename/functions.php – under all the existing code, as soon as the default code ends, I’m inserting it there, it completely breaks my dashboard.

    I’m really sorry for the lack of knowledge, I know my ways around programming and what not, but I’m really new to the wordpress platform, and you’re help as been already fantastic! Please tell me where I should insert the code so I can test it and report back. I have no problem understanding the code you sent me, only apply it.

    Once again thanks for the prompt response,
    Respectfully,
    Daniel

    Plugin Author Subrata Mal

    (@subratamal)

    @danielferreiraneto,

    You are in right path. Please reach out us at [email protected] for extended support because support here is limited.

    Thanks and Regards,
    Subrata Mal

    This code is not working in my site. On checkout page “via wallet” money become 0 after pasting the above code in function.php

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Maximum Wallet Usage Capped to Cart Total Percentage’ is closed to new replies.