Limit partial payment to 20% of order total2019-12-04T20:43:49+05:30

Home Forums Core Limit partial payment to 20% of order total

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • mnkhalid2000
    Participant
    Post count: 1

    Hi I am trying to use the below code that was shared in wordpress support but it breaks my website with a critical error. Please help

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

    Subrata Mal
    Keymaster
    Post count: 175

    Please use updated code attached

    • This reply was modified 2 years, 5 months ago by Subrata Mal.
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.