• Resolved dasad0

    (@dasad0)


    Sir ,

    i want that user can only use 20% of their wallet for their purchase , but it does not apply on shipping charge ,

    i use this code , it work but it also add shipping charge –

    
    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;
    }
    

    EXample – Product value – 100 , Shipping 20 , then buyer can use 20 as 20% from wallet and he has to pay Rs 80+ Full shipping charges

    • This topic was modified 5 years, 7 months ago by Jan Dembowski.
    • This topic was modified 5 years, 7 months ago by Jan Dembowski. Reason: Formatting
Viewing 1 replies (of 1 total)
  • Plugin Author Subrata Mal

    (@subratamal)

    @dasad0 Please use below updated code.

    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 = wc()->cart->get_subtotal( 'edit' );
            $partial_payment_amount = ($cart_total * 20) / 100;
            if ($amount >= $partial_payment_amount) {
                $amount = $partial_payment_amount;
            }
        }
        return $amount;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘WooCommerce Wallet uses Limit’ is closed to new replies.