"Add to Card" broken when custom class "uk-card" in commerce-product.html.twig template

Created on 8 March 2023, almost 2 years ago
Updated 9 March 2023, almost 2 years ago

"Add to Card" broken when custom class "uk-card" exists in commerce-product.html.twig template

I use the UIkit framework. The component card suppose a "uk-card" class.
I override the commerce-product.html.twig to encapsulate products infos inside a card.
(I have a custom event subscriber to redirect user to checkout just after adding a product)
Everything worked fine from years with previous release of commerce core module, but it's now broken with the 8.x-2.33.

Step to reproduce

{% set main_classes = [
  'uk-card',
  'uk-card-default',
  'uk-flex',
  'uk-flex-column'
]
%}
<article{{ attributes.addClass(main_classes).setAttribute('data-uk-scrollspy-class', 'uk-animation-slide-left-small') }}>
  <div class="uk-card-header uk-text-center">
    <h4 class="uk-text-bold">{{ product.title.0 }}</h4>
  </div>
  <div class="uk-card-body">
    <div class="uk-text-center">
      {{ product.variation_price }}
      {{- product.body -}}
    </div>
  </div>
  <div class="uk-card-footer">
    {{- product|without('variation_attributes', 'title', 'variation_price', 'body') -}}
  </div>
</article>

Not working. The user is redirect to current_page_urlundefined !

{% set main_classes = [
  'uk-card-default',
  'uk-flex',
  'uk-flex-column'
]
%}
<article{{ attributes.addClass(main_classes).setAttribute('data-uk-scrollspy-class', 'uk-animation-slide-left-small') }}>
  <div class="uk-card-header uk-text-center">
    <h4 class="uk-text-bold">{{ product.title.0 }}</h4>
  </div>
  <div class="uk-card-body">
    <div class="uk-text-center">
      {{ product.variation_price }}
      {{- product.body -}}
    </div>
  </div>
  <div class="uk-card-footer">
    {{- product|without('variation_attributes', 'title', 'variation_price', 'body') -}}
  </div>
</article>

Working !

It's really surprising !!! Maybe the class name which close to "cart" plays...

🐛 Bug report
Status

Closed: works as designed

Version

2.33

Component

Product

Created by

🇫🇷France mitsuko

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

Comments & Activities

Production build 0.71.5 2024