How to skip customer profile / billing information if order total is zero

Created on 15 May 2024, 7 months ago
Updated 7 June 2024, 7 months ago

I have everything working for a D10 site using drupal/commerce and drupal/commerce_stripe

For the Stripe payment gateway settings, I have deselected "Collect billing information," so that the billing information form does not appear during checkout. This works great.

However, if the order total is $0.00, I want the customer to checkout immediately without the requirement to enter billing information. The billing information is always required for free orders, and I cannot, for the life of me, figure out how to get rid of it.

💬 Support request
Status

Fixed

Version

2.39

Component

Checkout

Created by

🇺🇸United States carsonw

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @carsonw
  • 🇮🇱Israel jsacksick
     if (!$this->order->getTotalPrice() || $this->order->isPaid() || $this->order->getTotalPrice()->isZero()) {
          // No payment is needed if the order is free or has already been paid.
          // In that case, collect just the billing information.
          $pane_form['#title'] = $this->t('Billing information');
          $pane_form = $this->buildBillingProfileForm($pane_form, $form_state);
          return $pane_form;
        }

    Hm... You probably have to implement hook_form_alter() to alter the checkout form and set #access FALSE to the billing information form element.
    Should be accessible under $form['payment_information']['billing_information'].
    I haven't tested that though... Otherwise you could swap the payment information pane checkout pane with your own class to you can override the isVisible() method for example and return FALSE from there if the order is free.

    I don't see a no code solution for this unfortunately.

  • Status changed to Fixed 7 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024