TypeError when starting donation process

Created on 11 October 2024, about 1 month ago

Steps to reproduce:

1. Go to mywebsite.com/donate as anonymous user.

2. Select an amount. Click "Continue to Payment" button.

3. Arrive at white screen of death, displaying generic "The website encountered an unexpected error. Try again later." error message.

4. Check the logs, find the following:
TypeError: reset(): Argument #1 ($array) must be of type array, null given in reset() (line 244 of /home1/mywebsite/public_html/modules/contrib/commerce_donation_flow/src/Plugin/Field/FieldWidget/DonationLevelWidget.php).

When I replicate those steps as admin user, I can't even access the /donate page (I get a WSOD). This is the log message in that instance:

TypeError: CommerceGuys\Intl\Formatter\CurrencyFormatter::format(): Argument #2 ($currencyCode) must be of type string, null given, called in /home1/mywebsite/public_html/modules/contrib/commerce_donation_flow/src/Plugin/Commerce/CheckoutFlow/DonationCheckoutFlow.php on line 209 in CommerceGuys\Intl\Formatter\CurrencyFormatter->format() (line 93 of /home1/mywebsite/vendor/commerceguys/intl/src/Formatter/CurrencyFormatter.php).

Then, if I log out and log back in as admin, I CAN access the /donate page, but I then I experience the same error as the anonymous user.

How can I resolve these issues?

πŸ’¬ Support request
Status

Active

Version

1.1

Component

Miscellaneous

Created by

πŸ‡ΊπŸ‡ΈUnited States hockey2112

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

Comments & Activities

  • Issue created by @hockey2112
  • πŸ‡ΊπŸ‡ΈUnited States fathershawn New York

    If you have your site configured for Option 2 (standard checkout) as you stated in πŸ’¬ Donation checkout flow not being displayed in config Active then the /donate route isn't going to work. That's the beginning of a dedicated checkout process that only does donations.

  • πŸ‡ΊπŸ‡ΈUnited States fathershawn New York
  • πŸ‡ΊπŸ‡ΈUnited States hockey2112

    I changed my setup to "Allow both". I also decided to uninstall and reinstall, in case something got "twisted up" during my original setup.

    Here's what I've got:

    /admin/commerce/config/donation-settings

    "Allow both" is selected

    Configuration for /donate route: 
    OrderItem to use on /donate: Donation
    
    Order to use with the OrderItem chosen above: Default
    (I did create a new Order type called "Donation", but if I select it here and save, the setting simply reverts back to "Default". Bug? See the red arrows.)
    
    Checkout Flow: Donation Flow
    Configuration for /cart route: 
    OrderItem to use with /cart | /checkout: Default
    
    Order to use with the OrderItem chosen above: Default
    
    Checkout flow: Default

    I notice that the "both" configuration scenario states:

    "You will need to create extensions of the donation and memorial panes that select for your additional OrderItem type, and use those panes in the checkout flow which you configure to use this second OrderItem."

    What specific action do I need to take to do that? Or is that already done by way of me moving the "Add a Donation" item to the first step of the Donation Order Flow?

    Thank you!

  • πŸ‡ΊπŸ‡ΈUnited States fathershawn New York

    "You will need to create extensions of the donation and memorial panes that select for your additional OrderItem type, and use those panes in the checkout flow which you configure to use this second OrderItem."

    The included checkout panes, regardless of which setup is used, look for donation OrderItems. Using both checkout routes is an advanced scenario that requires having a second OrderItem type created and then coding checkout panes to look for that type. This can be done by extending the existing pane plugins but the module does not currently offer out of the box for this scenario.

  • πŸ‡ΊπŸ‡ΈUnited States hockey2112

    I'm not sure I follow. Installation of the module auto-created a "donation" Order Item Type. Are you saying I need to create an additional Order Item Type, for example "donation_2", that will then be used in an additional Checkout Flow that I must manually create?

    Maybe my disconnect is that I am expecting the donation route to use one flow, and normal ecommerce to use another flow. I don't want ecommerce customers to be able to "also donate" in the same checkout, and likewise I do not want donation customers to be able to "also order a product" in the same checkout.

    With that personal requirement in mind, is that possible with this module?

  • πŸ‡ΊπŸ‡ΈUnited States fathershawn New York

    It's not possible with the provided checkout panes.

    The client that this module was developed to support did not have any commerce beyond donations. After this code was released as a contributed module, donations along side the purchase of actual goods was requested by several users and I built a second checkout flow plugin to support that. However, all the plugins in this module are built to support the dedicated donation OrderItem. OrderItems are always paired with an Order in Commerce which is paired with a Checkout flow. So to support two flows, the checkout panes and the Donation order controller would all need to be configurable as to which OrderItem was expected in each flow. That's not the current state of the code.

  • πŸ‡ΊπŸ‡ΈUnited States hockey2112

    OK thank you for your patience, greatly appreciated!

  • πŸ‡ΊπŸ‡ΈUnited States fathershawn New York
  • πŸ‡ΊπŸ‡ΈUnited States fathershawn New York

    Absolutely! Happy to help.

Production build 0.71.5 2024