• Resolved samshubbua

    (@samshubbua)


    Hello,
    this code is not working for me can u please support me on this,
    i want users not to use whole wallet amount as i am giving them some membership coupons so that they can just use 15% of the wallet money and rest from the payment option,
    i found this code but it didn’t work

    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 * 15) / 100;
    }
    } else if (sizeof(wc()->cart->get_cart()) > 0) {
    $cart_total = wc()->cart->get_total(‘edit’);
    if ($amount > $cart_total) {
    $amount = ($cart_total * 15) / 100;
    }
    }
    return $amount;
    }

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

    (@subratamal)

    Please use update code.

    add_filter('is_valid_payment_through_wallet', '__return_false');
    add_filter('woo_wallet_partial_payment_amount', 'woo_wallet_partial_payment_amount_callback', 100);
    
    function woo_wallet_partial_payment_amount_callback($amount) {
        if (sizeof(WC()->cart->get_cart()) > 0) {
            $totals = WC()->cart->get_totals();
            $cart_total = $totals['subtotal'] + $totals['shipping_total'] + $totals['subtotal_tax'] + $totals['shipping_tax'];
            $amount = ($cart_total * 15) / 100;
            if ($amount > woo_wallet()->wallet->get_wallet_balance(get_current_user_id(), 'edit')) {
                $amount = woo_wallet()->wallet->get_wallet_balance(get_current_user_id(), 'edit');
            }
        }
        return $amount;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Limit wallet money usage on products’ is closed to new replies.