[Shop] Reorganize Twig hooks on cart index page (#17364)

| Q               | A
|-----------------|-----
| Branch?         | 2.0 
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | not yet
| Deprecations?   | no
| Related tickets | 
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.13 branch
 - Features and deprecations must be submitted against the 1.14 branch
- Features, removing deprecations and BC breaks must be submitted
against the 2.0 branch
 - Make sure that the correct base branch is set

To be sure you are not breaking any Backward Compatibilities, check the
documentation:

https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->


![image](https://github.com/user-attachments/assets/c6a747dc-b6cf-4951-a931-76f0643fb06a)
This commit is contained in:
Grzegorz Sadowski 2024-11-04 14:06:21 +01:00 committed by GitHub
commit fb080519d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 44 additions and 41 deletions

View file

@ -173,7 +173,7 @@ class SummaryPage extends ShopPage implements SummaryPageInterface
public function cartIsEmpty(): bool public function cartIsEmpty(): bool
{ {
return str_contains($this->getElement('flash_message')->getText(), 'Your cart is empty'); return str_contains($this->getElement('flash_message_info')->getText(), 'Your cart is empty');
} }
public function getQuantity(string $productName): int public function getQuantity(string $productName): int
@ -226,7 +226,7 @@ class SummaryPage extends ShopPage implements SummaryPageInterface
'checkout_button' => '[data-test-cart-checkout-button]', 'checkout_button' => '[data-test-cart-checkout-button]',
'clear_cart' => '[data-test-clear-cart]', 'clear_cart' => '[data-test-clear-cart]',
'coupon_field' => '[data-test-cart-promotion-coupon-input]', 'coupon_field' => '[data-test-cart-promotion-coupon-input]',
'flash_message' => '[data-test-sylius-flash-message]', 'flash_message_info' => '[data-test-sylius-flash-message="alert-info"]',
'form' => '[data-live-name-value="sylius_shop:cart:form"]', 'form' => '[data-live-name-value="sylius_shop:cart:form"]',
'summary_component' => '[data-live-name-value="sylius_shop:cart:summary"]', 'summary_component' => '[data-live-name-value="sylius_shop:cart:summary"]',
'grand_total' => '[data-test-cart-grand-total]', 'grand_total' => '[data-test-cart-grand-total]',

View file

@ -1,11 +1,16 @@
sylius_twig_hooks: sylius_twig_hooks:
hooks: hooks:
'sylius_shop.cart.index': 'sylius_shop.cart.index':
content:
template: '@SyliusShop/cart/index/content.html.twig'
priority: 0
'sylius_shop.cart.index.content':
form: form:
component: 'sylius_shop:cart:form' component: 'sylius_shop:cart:form'
props: props:
resource: '@=_context.cart' resource: '@=_context.cart'
template: '@SyliusShop/cart/index/form.html.twig' template: '@SyliusShop/cart/index/content/form.html.twig'
priority: 100 priority: 100
suggested_products: suggested_products:
component: 'sylius_shop:product:list' component: 'sylius_shop:product:list'
@ -16,106 +21,106 @@ sylius_twig_hooks:
title: 'sylius.ui.you_may_also_like' title: 'sylius.ui.you_may_also_like'
priority: 0 priority: 0
'sylius_shop.cart.index.header': 'sylius_shop.cart.index.content.header':
flashes: flashes:
enabled: false enabled: false
'sylius_shop.cart.index.form': 'sylius_shop.cart.index.content.form':
sections: sections:
template: '@SyliusShop/cart/index/form/sections.html.twig' template: '@SyliusShop/cart/index/content/form/sections.html.twig'
priority: 0 priority: 0
'sylius_shop.cart.index.form.sections': 'sylius_shop.cart.index.content.form.sections':
flashes: flashes:
template: "@SyliusShop/shared/flashes.html.twig" template: "@SyliusShop/shared/flashes.html.twig"
priority: 200 priority: 200
header: header:
template: '@SyliusShop/cart/index/form/sections/header.html.twig' template: '@SyliusShop/cart/index/content/form/sections/header.html.twig'
priority: 100 priority: 100
general: general:
template: '@SyliusShop/cart/index/form/sections/general.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general.html.twig'
priority: 0 priority: 0
'sylius_shop.cart.index.form.sections.general#left': 'sylius_shop.cart.index.content.form.sections.general#left':
items: items:
template: '@SyliusShop/cart/index/form/sections/general/items.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/items.html.twig'
priority: 200 priority: 200
coupon: coupon:
template: '@SyliusShop/cart/index/form/sections/general/coupon.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/coupon.html.twig'
priority: 100 priority: 100
clear_cart: clear_cart:
template: '@SyliusShop/cart/index/form/sections/general/clear_cart.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/clear_cart.html.twig'
priority: 0 priority: 0
'sylius_shop.cart.index.form.sections.general#right': 'sylius_shop.cart.index.content.form.sections.general#right':
summary: summary:
component: 'sylius_shop:cart:summary' component: 'sylius_shop:cart:summary'
props: props:
cart: '@=_context.cart' cart: '@=_context.cart'
template: '@SyliusShop/cart/index/form/sections/general/summary.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/summary.html.twig'
priority: 100 priority: 100
checkout: checkout:
template: '@SyliusShop/cart/index/form/sections/general/checkout.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/checkout.html.twig'
priority: 0 priority: 0
'sylius_shop.cart.index.form.sections.general.items': 'sylius_shop.cart.index.content.form.sections.general.items':
head: head:
template: '@SyliusShop/cart/index/form/sections/general/items/head.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/items/head.html.twig'
priority: 100 priority: 100
body: body:
template: '@SyliusShop/cart/index/form/sections/general/items/body.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/items/body.html.twig'
priority: 0 priority: 0
'sylius_shop.cart.index.form.sections.general.items.head': 'sylius_shop.cart.index.content.form.sections.general.items.head':
remove: remove:
template: '@SyliusShop/cart/index/form/sections/general/items/head/remove.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/items/head/remove.html.twig'
priority: 400 priority: 400
item: item:
template: '@SyliusShop/cart/index/form/sections/general/items/head/item.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/items/head/item.html.twig'
priority: 300 priority: 300
unit_price: unit_price:
template: '@SyliusShop/cart/index/form/sections/general/items/head/unit_price.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/items/head/unit_price.html.twig'
priority: 200 priority: 200
quantity: quantity:
template: '@SyliusShop/cart/index/form/sections/general/items/head/quantity.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/items/head/quantity.html.twig'
priority: 100 priority: 100
total: total:
template: '@SyliusShop/cart/index/form/sections/general/items/head/total.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/items/head/total.html.twig'
priority: 0 priority: 0
'sylius_shop.cart.index.form.sections.general.items.body': 'sylius_shop.cart.index.content.form.sections.general.items.body':
remove: remove:
template: '@SyliusShop/cart/index/form/sections/general/items/body/remove.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/items/body/remove.html.twig'
priority: 400 priority: 400
item: item:
template: '@SyliusShop/cart/index/form/sections/general/items/body/item.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/items/body/item.html.twig'
priority: 300 priority: 300
unit_price: unit_price:
template: '@SyliusShop/cart/index/form/sections/general/items/body/unit_price.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/items/body/unit_price.html.twig'
priority: 200 priority: 200
quantity: quantity:
template: '@SyliusShop/cart/index/form/sections/general/items/body/quantity.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/items/body/quantity.html.twig'
priority: 100 priority: 100
total: total:
template: '@SyliusShop/cart/index/form/sections/general/items/body/total.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/items/body/total.html.twig'
priority: 0 priority: 0
'sylius_shop.cart.index.form.sections.general.summary': 'sylius_shop.cart.index.content.form.sections.general.summary':
items_total: items_total:
template: '@SyliusShop/cart/index/form/sections/general/summary/items_total.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/summary/items_total.html.twig'
priority: 500 priority: 500
discount: discount:
template: '@SyliusShop/cart/index/form/sections/general/summary/discount.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/summary/discount.html.twig'
priority: 400 priority: 400
estimated_cost: estimated_cost:
template: '@SyliusShop/cart/index/form/sections/general/summary/estimated_cost.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/summary/estimated_cost.html.twig'
priority: 300 priority: 300
taxes_total: taxes_total:
template: '@SyliusShop/cart/index/form/sections/general/summary/taxes_total.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/summary/taxes_total.html.twig'
priority: 200 priority: 200
order_total: order_total:
template: '@SyliusShop/cart/index/form/sections/general/summary/order_total.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/summary/order_total.html.twig'
priority: 100 priority: 100
base_currency_order_total: base_currency_order_total:
template: '@SyliusShop/cart/index/form/sections/general/summary/base_currency_order_total.html.twig' template: '@SyliusShop/cart/index/content/form/sections/general/summary/base_currency_order_total.html.twig'
priority: 0 priority: 0

View file

@ -6,7 +6,5 @@
{% block title %}{{ 'sylius.ui.your_shopping_cart'|trans }} | {{ parent() }}{% endblock %} {% block title %}{{ 'sylius.ui.your_shopping_cart'|trans }} | {{ parent() }}{% endblock %}
{% block content %} {% block content %}
<div class="container mt-4 mb-5"> {% hook cart_hook with { cart, form } %}
{% hook cart_hook with { cart, form } %}
</div>
{% endblock %} {% endblock %}