- Issue created by @alexberendei
- Status changed to Needs work
7 months ago 4:26pm 16 May 2024 - First commit to issue fork.
- Status changed to Needs review
6 months ago 11:41am 28 May 2024
Error: Call to a member function get() on bool in Drupal\bee_hotel\Resolvers\SalepriceResolver->resolve() (line 106 of /app/web/modules/contrib/bee_hotel/src/Resolvers/SalepriceResolver.php).
Operations
#0 /app/web/modules/contrib/commerce/modules/price/src/Resolver/ChainPriceResolver.php(49): Drupal\bee_hotel\Resolvers\SalepriceResolver->resolve(Object(Drupal\commerce_product\Entity\ProductVariation), 1, Object(Drupal\commerce\Context))
#1 /app/web/modules/contrib/commerce/modules/order/src/PriceCalculator.php(106): Drupal\commerce_price\Resolver\ChainPriceResolver->resolve(Object(Drupal\commerce_product\Entity\ProductVariation), 1, Object(Drupal\commerce\Context))
#2 /app/web/modules/contrib/commerce/modules/order/src/Plugin/Field/FieldFormatter/PriceCalculatedFormatter.php(171): Drupal\commerce_order\PriceCalculator->calculate(Object(Drupal\commerce_product\Entity\ProductVariation), 1, Object(Drupal\commerce\Context), Array)
#3 /app/web/core/lib/Drupal/Core/Field/FormatterBase.php(91): Drupal\commerce_order\Plugin\Field\FieldFormatter\PriceCalculatedFormatter->viewElements(Object(Drupal\Core\Field\FieldItemList), 'en')
#4 /app/web/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php(268): Drupal\Core\Field\FormatterBase->view(Object(Drupal\Core\Field\FieldItemList), 'en')
#5 /app/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(339): Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array)
#6 /app/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(281): Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'full')
#7 /app/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(238): Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array)
#8 [internal function]: Drupal\Core\Entity\EntityViewBuilder->build(Array)
#9 /app/web/modules/contrib/commerce/modules/product/src/ProductVariationFieldRenderer.php(37): call_user_func(Array, Array)
#10 /app/web/modules/contrib/commerce/modules/product/src/ProductViewBuilder.php(96): Drupal\commerce_product\ProductVariationFieldRenderer->renderFields(Object(Drupal\commerce_product\Entity\ProductVariation), 'full')
#11 /app/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(291): Drupal\commerce_product\ProductViewBuilder->alterBuild(Array, Object(Drupal\commerce_product\Entity\Product), Object(Drupal\Core\Entity\Entity\EntityViewDisplay), 'full')
#12 /app/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(238): Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array)
#13 [internal function]: Drupal\Core\Entity\EntityViewBuilder->build(Array)
#14 /app/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(111): call_user_func_array(Array, Array)
#15 /app/web/core/lib/Drupal/Core/Render/Renderer.php(859): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')
#16 /app/web/core/lib/Drupal/Core/Render/Renderer.php(421): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)
#17 /app/web/core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, false)
#18 /app/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(238): Drupal\Core\Render\Renderer->render(Array, false)
#19 /app/web/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#20 /app/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(239): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#21 /app/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(128): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#22 /app/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#23 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#24 /app/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#25 /app/vendor/symfony/http-kernel/HttpKernel.php(186): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view')
#26 /app/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#27 /app/web/modules/contrib/bat_api/src/StackMiddleware/BatApiMiddleware.php(39): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Drupal\bat_api\StackMiddleware\BatApiMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 /app/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 /app/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#34 /app/web/modules/contrib/services/src/StackMiddleware/FormatSetter.php(45): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#35 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\services\StackMiddleware\FormatSetter->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#36 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#37 /app/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#38 /app/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#39 /app/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#40 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#41 {main}
Store has multiple currencies and the error points to this line:
$data['currency_code'] = $data['store']->get('default_currency')->getValue()[0]['target_id'];
Replace this line: $data['currency_code'] = $data['store']->get('default_currency')->getValue()[0]['target_id'];
With this fallback code:
// Check if $data['store'] is an object before calling methods on it
if (is_object($data['store']) && $data['store']->hasField('default_currency')) {
// Get the default_currency field value if available, otherwise set a fallback value
$currency_code = $data['store']->get('default_currency')->isEmpty() ? 'fallback_currency_code' : $data['store']->get('default_currency')->getValue()[0]['target_id'];
} else {
// Set a fallback value if $data['store'] is not an object or if default_currency field is not available
$currency_code = 'USD';
}
$data['currency_code'] = $currency_code;
Needs review
2.21
Code