Promotions do not apply - TypeError: implode(): Argument #1 ($pieces) must be of type array, string given in implode()

Created on 18 March 2024, 3 months ago
Updated 10 May 2024, about 2 months ago

Describe your bug or feature request.

I'm trying to create a simple promotion that always applies. 90% "off each matching product". I've added no conditions (and experimented by selecting all product types or all roles) but under no circumstance is the promotion applied.

When I use a coupon and try to apply it, an error is printed in the log:
TypeError: implode(): Argument #1 ($pieces) must be of type array, string given in implode() (line 26 of /var/www/xxx/core/lib/Drupal/Core/Form/FormElementHelper.php).

Full stack trace:

#0 /var/www/***/core/lib/Drupal/Core/Form/FormElementHelper.php(26): implode()
#1 /var/www/***/core/lib/Drupal/Core/Form/FormElementHelper.php(29): Drupal\Core\Form\FormElementHelper::getElementByName()
#2 /var/www/***/core/lib/Drupal/Core/Form/FormElementHelper.php(29): Drupal\Core\Form\FormElementHelper::getElementByName()
#3 /var/www/***/core/lib/Drupal/Core/Form/FormElementHelper.php(29): Drupal\Core\Form\FormElementHelper::getElementByName()
#4 /var/www/***/core/lib/Drupal/Core/Form/FormElementHelper.php(29): Drupal\Core\Form\FormElementHelper::getElementByName()
#5 /var/www/***/core/lib/Drupal/Core/Form/FormElementHelper.php(29): Drupal\Core\Form\FormElementHelper::getElementByName()
#6 /var/www/***/core/lib/Drupal/Core/Form/FormElementHelper.php(29): Drupal\Core\Form\FormElementHelper::getElementByName()
#7 /var/www/***/core/modules/inline_form_errors/src/FormErrorHandler.php(81): Drupal\Core\Form\FormElementHelper::getElementByName()
#8 /var/www/***/core/lib/Drupal/Core/Form/FormErrorHandler.php(23): Drupal\inline_form_errors\FormErrorHandler->displayErrorMessages()
#9 /var/www/***/core/lib/Drupal/Core/Form/FormValidator.php(199): Drupal\Core\Form\FormErrorHandler->handleFormErrors()
#10 /var/www/***/core/lib/Drupal/Core/Form/FormValidator.php(119): Drupal\Core\Form\FormValidator->finalizeValidation()
#11 /var/www/***/core/lib/Drupal/Core/Form/FormBuilder.php(593): Drupal\Core\Form\FormValidator->validateForm()
#12 /var/www/***/core/lib/Drupal/Core/Form/FormBuilder.php(325): Drupal\Core\Form\FormBuilder->processForm()
#13 /var/www/***/core/lib/Drupal/Core/Form/FormBuilder.php(224): Drupal\Core\Form\FormBuilder->buildForm()
#14 /var/www/***/modules/contrib/commerce/modules/checkout/src/Controller/CheckoutController.php(143): Drupal\Core\Form\FormBuilder->getForm()
#15 [internal function]: Drupal\commerce_checkout\Controller\CheckoutController->formPage()
#16 /var/www/***/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#17 /var/www/***/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#18 /var/www/***/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#19 /var/www/***/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#20 /var/www/***/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#21 /var/www/***/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#22 /var/www/***/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#23 /var/www/***/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#24 /var/www/***/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#25 /var/www/***/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\ContentLength->handle()
#26 /var/www/***/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#27 /var/www/***/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#28 /var/www/***/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#29 /var/www/***/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#30 /var/www/***/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#31 /var/www/***/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#32 /var/www/***/index.php(19): Drupal\Core\DrupalKernel->handle()
#33 {main}

If a bug, provide steps to reproduce it from a clean install.

Install drupal core 10.2.4
Install commerce and all related modules
Create a promotion either with or without a coupon and try to have it apply without any, or under any condition.

🐛 Bug report
Status

Closed: won't fix

Version

2.38

Component

Promotions

Created by

🇹🇭Thailand AlfTheCat

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

Comments & Activities

  • Issue created by @AlfTheCat
  • 🇹🇭Thailand AlfTheCat

    To clarify, using coupons also doesn't work, an "Oops, something went wrong, check your browser console" message is shown.

  • 🇮🇱Israel jsacksick

    I can see the "inline_form_errors" in the backtrace... Did you try disabling that temporarily? I've never experiened this before but I'm also not using this module...

  • 🇹🇭Thailand AlfTheCat

    Hi @jsacksick,

    Thanks very much for the quick reply and great insight, I uninstalled the module, and now promotions are working. What is very strange is that without using a coupon the inline_form_errors module also prevents the promotion from being applied.

    Who knows where else inline_form_errors could be causing problems because I've been suffering many, seemingly random "oops, something went wrong" errors after routinely updating Drupal.

    Seems like this is a Drupal Core bug, or should it be investigated from the side of Drupal commerce as well?

    Again, thank you!

  • 🇮🇱Israel jsacksick

    Seems like this is a Drupal Core bug, or should it be investigated from the side of Drupal commerce as well?

    Hard to tell... Would need to try reproducing this myself but since it works without this module enabled... Well could be a core bug.

  • 🇹🇭Thailand AlfTheCat

    Alright, I filed this in the Drupal queue: 🐛 Inline form errors breaks Commerce Promotions Active . Let's see what people say over there :)

  • Status changed to Closed: won't fix about 2 months ago
Production build 0.69.0 2024