Payment Information box on Order Information page of the checkout flow is empty

Created on 1 January 2024, almost 2 years ago
Updated 26 January 2024, over 1 year ago

Problem/Motivation

Problem: Payment Information box on Order Information page of the checkout flow is empty.

Motivation a: This can trigger site builders to disable the payment information pane in the checkout flow and cause the paypal smart buttons to not render on the checkout review page.

Motivation b: This makes the learning curve for new site developers very difficult when trying to test the module for first time and determine how it works. It may not be detected as a bug but being empty leads to confusion.

Steps to reproduce

Install Drupal.

Enable the following modules: commerce_paypal commerce_product commerce_cart commerce_checkout

* Login to fresh install of Drupal.
* Add a store.
* Add a payment gateway configured to use the Paypal checkout (Preferred) plugin
* Add a product
* Add a product variation.
* View the product
* click "add to cart"
* go to /cart
* click "checkout"
Witness the empty "Payment information" panel.

Proposed resolution

Apply this patch

This patch may not be the correct fix.
Here is the patch inline, it is a one liner:

diff --git a/src/PluginForm/Checkout/PaymentMethodAddForm.php b/src/PluginForm/Checkout/PaymentMethodAddForm.php
index 8a5b49f..c87b3da 100644
--- a/src/PluginForm/Checkout/PaymentMethodAddForm.php
+++ b/src/PluginForm/Checkout/PaymentMethodAddForm.php
@@ -78,6 +78,7 @@ class PaymentMethodAddForm extends BasePaymentMethodAddForm {
     // We need to inject the custom card fields, only when this is the solution
     // configured.
     if (!$this->shouldInjectForm($payment_method->getPaymentGateway()->getPlugin())) {
+      $form['#access'] = FALSE;
       return $form;
     }
     /** @var \Drupal\commerce_order\Entity\OrderInterface $order */

The purpose of this patch is to trigger the following code from the commerce module to behave:
modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowWithPanesBase.php:548

547:      // Avoid rendering an empty container.
548:      $form[$pane_id]['#access'] = (bool) Element::getVisibleChildren($form[$pane_id]);

Prior to my patch Element::getVisibleChildren($form[$pane_id]) is returning an array containing 'add_payment_method'.
The addition of $form['#access'] = FALSE; causes that to return an empty array and thus not display the empty container.

Remaining tasks

* Reproduce the empty payment information pane.
* Apply the patch
* Witness the payment information pane hidden.

* Determine if the issue is in fact in the commerce module's logic for detecting an empty container and potentially fix that instead.

User interface changes

Hidden 'payment information' pane.

API changes

None.

Further information

It appears that other users may be experiencing the same confusion and possibly making the same incorrect assumptions that I did, see Paypal smart buttons showing on cart page not review or payment page 💬 Paypal smart buttons showing on cart page not review or payment page Active .

The combination of my inexperience with this module, other misconfiguration that obscured it, caching causing false positives and false negatives, lack of understanding of what that payment information box was supposed to do and inability to see it doing what it is supposed to do so as to learn caused me to make the reasonable assumption of "In my case the payment information is empty. I do not want to display an empty fieldset to my users, I will disable it in the checkout flow". Disabling the payment information caused the PayPal buttons to disappear without any notices in the log, warnings or anything. Given that the payment information appeared to be optional due to the fact that it could be disabled and was empty, it seemed perfectly reasonable to disable it.

I had seen the payment buttons not appear earlier because I had been assigning the "PayPal check flow" to the default order type. This caused the same symptom of "PayPal smart buttons showing on cart page not review or payment page". Along with above mentioned cache issues, this was one more complexity on top of my already confused understanding. It took many hours of trial, error, clearing caches, reconfiguration, thinking it was working, then it's not working before I got the issue simple enough to replicate consistently using the above mentioned steps.

In summary, this pane being rendered with nothing in it leads to confusion on top of an already complex module as is a major barrier to a new site builder's already steep learning curve, and in at least my case triggered me to disable it which silently made things worse.

P.S. This only happens the FIRST time one views the order information page.
If you click through to the review page it will show 'paypal' text. If you click on 'edit' in that panel and go back to the order information page the paypal radio button will show.
If you remove the product from the cart and add it back again, then click 'checkout' the radio button will appear again.

🐛 Bug report
Status

Fixed

Version

1.0

Component

PayPal Checkout

Created by

🇦🇺Australia thursday_bw

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

Comments & Activities

Production build 0.71.5 2024