Comments (3)
After short discussion with @GSadee & @NoResponseMate we are aiming to fix it in 2.0
from sylius.
If you're looking for a real world example of this problem, I can provide that.
Add an “Add to Cart” button to the card content. To do this, you can only fix one file.
File '@SyliusShop/Product/Box/_content.html.twig'
{% import "@SyliusShop/Common/Macro/money.html.twig" as money %}
<div class="ui fluid card" {{ sylius_test_html_attribute('product') }}>
<a href="{{ path('sylius_shop_product_show', {'slug': product.slug, '_locale': product.translation.locale}) }}" class="blurring dimmable image">
<div class="ui dimmer">
<div class="content">
<div class="center">
<div class="ui inverted button">{{ 'sylius.ui.view_more'|trans }}</div>
</div>
</div>
</div>
{% include '@SyliusShop/Product/_mainImage.html.twig' with {'product': product} %}
</a>
<div class="content" {{ sylius_test_html_attribute('product-content') }}>
<a href="{{ path('sylius_shop_product_show', {'slug': product.slug, '_locale': product.translation.locale}) }}" class="header sylius-product-name" {{ sylius_test_html_attribute('product-name', product.name) }}>{{ product.name }}</a>
{% if not product.enabledVariants.empty() %}
{% set variant = product|sylius_resolve_variant %}
{% set price = money.calculatePrice(variant) %}
{% set originalPrice = money.calculateOriginalPrice(variant) %}
{% set appliedPromotions = variant.getAppliedPromotionsForChannel(sylius.channel) %}
{% include '@SyliusShop/Product/Show/_catalogPromotionLabels.html.twig' with {'appliedPromotions': appliedPromotions, 'withDescription': false} %}
{# RENDER “ADD TO CART” BUTTON #}
{{ render(url('sylius_shop_partial_cart_add_item', {'template': '@SyliusShop/Product/Show/_addToCart.html.twig', 'productId': product.id})) }}
{% if variant|sylius_has_discount({'channel': sylius.channel}) %}
<div class="sylius-product-original-price" {{ sylius_test_html_attribute('product-original-price') }}><del>{{ originalPrice }}</del></div>
{% endif %}
<div class="sylius-product-price" {{ sylius_test_html_attribute('product-price') }}>{{ price }}</div>
{% endif %}
</div>
</div>
Your taxon page now displays an "Add to Cart" button for all products (just needs a styling fix)
And the product page (where the "Variant selection method" is not “Variant choice”) works and the latest product widget looks like this.
But if you open the product page where "Variant Selection Method" is "Variant choice", an error will appear.
from sylius.
The root of the problem is that we are using two different form types based on the entity config behind one key in the form builder. Now, if both are used, Twig cache is misconfigured, and we have a cache hit for the appropriate key (_sylius_add_to_cart_cartItem_variant_entry_widget
) even though the block hierarchy is different.
We could change keys in our cart item type extension as follows:
https://gist.github.com/lchrusciel/d247fae6fa661867cbd0bbb8948f1cc1#file-cartitemtypeextension-php-L28-L41
instead of
My main concern is that it is kind of BC-Break and templates would need to be adjusted in two places (_variants.html.twig and _options.html.twig).
The best option would be to fix it in Symfony. Mostly, we could propose that if the cached value is false, we still iterate over the hierarchy. Fixed code could look like this: TwigRendererEngine.php
I hope that it helps!
from sylius.
Related Issues (20)
- Installation tutorial fails HOT 7
- Cart update success message displayed for empty discount code input
- Toast message does not close after multiple clicks on the close "X" icon HOT 1
- [CLI FEATURE] Command for deleting an admin user by the given username HOT 1
- [CLI FEATURE] Command for list available admin users
- BUG: [AdminBundle] missing <br> Tag in Product media tab twig template HOT 4
- Disabled products do not disappear from a cart HOT 1
- BUG: Missing spacing between upload image upload button in image_widget HOT 1
- How can I return back to the previous form page from the PRE_SUBMIT event with form values?
- [DOCS] Document available CLI commands for Sylius HOT 2
- Performance issue on admin dashboard HOT 5
- Wrong sorting of products in taxon after saving HOT 2
- Error When try to remove the last OrderItem of cart by Api HOT 1
- Issue with API Platform core v2.7.17 HOT 2
- [Order] Text going out of the frame in the Notes section HOT 2
- [UI] Different product box sizes on the product listing HOT 1
- Form errors during creation of product remove all product images
- [UI] Text going out of the frame in product description HOT 2
- [Refactor][ApiBundle] Unify section resolver usage HOT 1
- Unable to generate url for route sylius_shop_product_show when product slug contains slash HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sylius.