1

I want to hide the payment methods when the basket subtotal is "0"

i have few products in my website where price is "0" but the customer has to pay for shipping incase if they want to purchase the product i want to hide all the options for payment methods so there will be no transaction been made. Is this possible

2 Answers 2

0

In Magento 2 There is payment Method "Zero Subtotal checkout".

You just enable it. It will automatically appear when your total is zero and for hiding other payment we you have to do some customization.

1
  • Hi, i have tried that i found the option in Configuration->sales->payment methods "zero subtotal checkout" Enabled = Yes Title= No Payment information required New Order Status = "Not sure which one to pick" i picked suspected fraud but i can still see the payment method when i click checkout Commented Dec 11, 2018 at 10:27
0

You can use the below in your Model\Payment\paymentMethod.php file

    /**
     * @param \Magento\Quote\Api\Data\CartInterface|null $quote
     * @return bool
     */
    public function isAvailable(
        \Magento\Quote\Api\Data\CartInterface $quote = null
    ) {
        /*return parent::isAvailable($quote);*/
        return parent::isAvailable($quote) && !empty($quote) && $quote->getGrandTotal() <= 0;
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.