From 702918ab4d123a8d8e30ee44b22cf35a4a0bd56f Mon Sep 17 00:00:00 2001 From: janpalen Date: Mon, 16 Dec 2024 14:13:29 +0100 Subject: [PATCH] OP-550 - Change twig paths --- .../config/twig_hooks/order/show.yaml | 2 +- .../config/twig_hooks/product/shop/show.yaml | 6 +++ .../Product/_addProductBundleToCart.html.twig | 40 ------------------- .../addProductBundleToCart.html.twig | 29 ++++++++++++++ .../sections/items/body/item.html.twig} | 0 5 files changed, 36 insertions(+), 41 deletions(-) create mode 100644 src/Resources/config/twig_hooks/product/shop/show.yaml delete mode 100644 src/Resources/views/Shop/Product/_addProductBundleToCart.html.twig create mode 100644 src/Resources/views/Shop/Product/show/page/info/summary/add_to_cart/addProductBundleToCart.html.twig rename tests/Application/templates/bundles/SyliusAdminBundle/{Order/Show/Summary/_item.html.twig => order/show/content/sections/items/body/item.html.twig} (100%) diff --git a/src/Resources/config/twig_hooks/order/show.yaml b/src/Resources/config/twig_hooks/order/show.yaml index 71d319f6..d9b80478 100644 --- a/src/Resources/config/twig_hooks/order/show.yaml +++ b/src/Resources/config/twig_hooks/order/show.yaml @@ -2,5 +2,5 @@ sylius_twig_hooks: hooks: 'sylius_admin.order.show.content.sections.items.body': item: - template: '@SyliusAdmin/Order/Show/Summary/_item.html.twig' + template: '@SyliusAdmin/order/show/content/sections/items/body/item.html.twig' priority: 800 diff --git a/src/Resources/config/twig_hooks/product/shop/show.yaml b/src/Resources/config/twig_hooks/product/shop/show.yaml new file mode 100644 index 00000000..d8b9d997 --- /dev/null +++ b/src/Resources/config/twig_hooks/product/shop/show.yaml @@ -0,0 +1,6 @@ +sylius_twig_hooks: + hooks: + 'sylius_shop.product.show.content.info.summary.add_to_cart': + bundle: + template: "@BitBagSyliusProductBundlePlugin/Shop/product/show/page/info/summary/add_to_cart/addProductBundleToCart.html.twig" + priority: 20 diff --git a/src/Resources/views/Shop/Product/_addProductBundleToCart.html.twig b/src/Resources/views/Shop/Product/_addProductBundleToCart.html.twig deleted file mode 100644 index c87b3d8a..00000000 --- a/src/Resources/views/Shop/Product/_addProductBundleToCart.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{% set product = order_item.variant.product %} - -{% form_theme form '@SyliusShop/Form/theme.html.twig' %} - -
- {{ sonata_block_render_event('sylius.shop.product.show.before_add_to_cart', {'product': product, 'order_item': order_item}) }} - - {{ form_start(form, {'action': path('bitbag_sylius_product_bundle_shop_ajax_cart_add_product_bundle', {'productId': product.id}), 'attr': {'id': 'sylius-product-adding-to-cart', 'class': 'ui loadable form', 'novalidate': 'novalidate', 'data-redirect': path(configuration.getRedirectRoute('summary'))}}) }} - {{ form_errors(form) }} - - {% if not product.simple %} - {% if product.variantSelectionMethodChoice %} - {% include '@SyliusShop/Product/Show/_variants.html.twig' %} - {% else %} - {% include '@SyliusShop/Product/Show/_options.html.twig' %} - {% endif %} - {% endif %} - {{ form_row(form.cartItem.quantity) }} - -

{{ 'bitbag_sylius_product_bundle.ui.products_in_bundle'|trans }}

- - {% for item in form.productBundleItems %} -
- {% set data = item.vars.data %} - -

{{ data.quantity }} x {{ data.productVariant.product.name }}

- - {% if item.productVariant is defined %} - {{ form_row(item.productVariant) }} - {% endif %} -
- - {% endfor %} - - {{ sonata_block_render_event('sylius.shop.product.show.add_to_cart_form', {'product': product, 'order_item': order_item}) }} - - - {{ form_row(form._token) }} - {{ form_end(form, {'render_rest': false}) }} -
diff --git a/src/Resources/views/Shop/Product/show/page/info/summary/add_to_cart/addProductBundleToCart.html.twig b/src/Resources/views/Shop/Product/show/page/info/summary/add_to_cart/addProductBundleToCart.html.twig new file mode 100644 index 00000000..89831d37 --- /dev/null +++ b/src/Resources/views/Shop/Product/show/page/info/summary/add_to_cart/addProductBundleToCart.html.twig @@ -0,0 +1,29 @@ +{#{% if hookable_metadata.context.resource is defined %}#} +{{ dump() }} + {% set product = hookable_metadata.context.resource %} + {% if product.isBundle %} + {% set form = hookable_metadata.context.form %} + {% set configuration = hookable_metadata.context.configuration %} + {% set product_bundle_items = form.productBundleItems %} + + {% form_theme form '@SyliusShop/Form/theme.html.twig' %} + +
+

{{ 'bitbag_sylius_product_bundle.ui.products_in_bundle'|trans }}

+ {% for item in product_bundle_items %} + {% set data = item.vars.data %} +
+
+ + {{ data.quantity }} x {{ data.productVariant.product.name }} + + {% if item.productVariant is defined %} + {{ form_row(item.productVariant) }} + {% endif %} +
+
+ {% endfor %} +
+
+ {% endif %} +{#{% endif %}#} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_item.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/order/show/content/sections/items/body/item.html.twig similarity index 100% rename from tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_item.html.twig rename to tests/Application/templates/bundles/SyliusAdminBundle/order/show/content/sections/items/body/item.html.twig