Skip to content

Instantly share code, notes, and snippets.

@csavoronin
Created April 25, 2022 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csavoronin/c8aa7c5190f24566f2c280fc7ac16a62 to your computer and use it in GitHub Desktop.
Save csavoronin/c8aa7c5190f24566f2c280fc7ac16a62 to your computer and use it in GitHub Desktop.
[!] Design: Layouts: If the wrapper had a form, then block forms didn't work. Fixed.
diff --git a/design/themes/responsive/css/tygh/lite_checkout.less b/design/themes/responsive/css/tygh/lite_checkout.less
index 75dac359b48..9ab9a810e3e 100644
--- a/design/themes/responsive/css/tygh/lite_checkout.less
+++ b/design/themes/responsive/css/tygh/lite_checkout.less
@@ -814,6 +814,11 @@
visibility: hidden;
}
+// Blocks for lite checkout wrapper
+.litecheckout__payment-methods > .litecheckout__group > :not(.litecheckout__group):not(.litecheckout__container) {
+ margin: 0.5rem;
+ width: 100%;
+}
//MIXIN
.set_border_color (@color, @value) when (iscolor(@color)) {
diff --git a/design/themes/responsive/templates/views/block_manager/extract_nested_forms.tpl b/design/themes/responsive/templates/views/block_manager/extract_nested_forms.tpl
new file mode 100644
index 00000000000..5f4cb5fc864
--- /dev/null
+++ b/design/themes/responsive/templates/views/block_manager/extract_nested_forms.tpl
@@ -0,0 +1,61 @@
+{*
+ Import
+ ---
+ $wrapper
+ $content
+
+ Global
+ ---
+ $form
+ $start
+ $form_content
+ $form_tag
+ $form_id
+ $smarty.capture.wrapper
+
+ Insert
+ ---
+ $form_tag
+
+ Export
+ ---
+ $content
+*}
+
+{capture name="wrapper"}
+ {include file=$wrapper content=" "}
+{/capture}
+
+{if $smarty.capture.wrapper|strpos:"<form" && $content|strpos:"<form"}
+
+ {foreach "<form"|explode:$content as $form}
+ {if $form@first}
+ {continue}
+ {/if}
+
+ {* Get the content, tag, and ID of the form *}
+ {$form = "<form`$form`"}
+ {$start = $form|strpos:"<form"}
+ {$form_content = $form|substr:$start:($form|strpos:"</form" + 7 - $start)}
+ {$form_tag = "`$form_content|substr:0:($form_content|strpos:">" + 1)`</form>"}
+ {$form_id = $form_tag|substr:($form_content|strpos:"id=\"" + 4)}
+ {$form_id = $form_id|substr:0:($form_id|strpos:"\"")}
+
+ {* Link all fields to the form *}
+ {$content = $content|replace:$form_content:($form_content|replace:
+ "<form":"<x-form"|replace:
+ "</form":"</x-form"|replace:
+ "id=\"`$form_id`\">":"id=\"`$form_id`_base\">"|replace:
+ "<input":"<input form=\"`$form_id`\""|replace:
+ "<select":"<select form=\"`$form_id`\""|replace:
+ "<textarea":"<textarea form=\"`$form_id`\""|replace:
+ "<button":"<button form=\"`$form_id`\""
+ )}
+
+ {* Insert the form outside of the wrapper form *}
+ {$form_tag|replace:" class=\"":" class=\"hidden cm-outside-inputs " nofilter}
+
+ {* Export *}
+ {$content = $content scope=parent}
+ {/foreach}
+{/if}
diff --git a/design/themes/responsive/templates/views/block_manager/render/grid.tpl b/design/themes/responsive/templates/views/block_manager/render/grid.tpl
index b2f28ff542c..23b2e3b7942 100644
--- a/design/themes/responsive/templates/views/block_manager/render/grid.tpl
+++ b/design/themes/responsive/templates/views/block_manager/render/grid.tpl
@@ -14,6 +14,12 @@
{$width = $fluid_width|default:$grid.width}
<div class="span{$width} {if $grid.offset}offset{$grid.offset}{/if} {$grid.user_class}" >
{if $grid.wrapper}
+
+ {include file="views/block_manager/extract_nested_forms.tpl"
+ wrapper=$grid.wrapper
+ content=$content
+ }
+
{include file=$grid.wrapper content=$content}
{else}
{$content nofilter}
diff --git a/design/themes/responsive/templates/views/checkout/components/customer/billing.tpl b/design/themes/responsive/templates/views/checkout/components/customer/billing.tpl
index 86abd09af8a..390e9035163 100644
--- a/design/themes/responsive/templates/views/checkout/components/customer/billing.tpl
+++ b/design/themes/responsive/templates/views/checkout/components/customer/billing.tpl
@@ -36,8 +36,8 @@
</div>
<!--litecheckout_use_billing_address_form--></div>
-<div id="litecheckout_billing_address_wrapper">
- <div class="litecheckout__container {if !$use_billing_address}hidden{/if}" id="litecheckout_step_billing_address">
+<div class="litecheckout__container" id="litecheckout_billing_address_wrapper">
+ <div class="{if !$use_billing_address}hidden{/if}" id="litecheckout_step_billing_address">
<div class="litecheckout__group">
<input
type="hidden"
diff --git a/design/themes/responsive/templates/views/checkout/components/promotion_coupon.tpl b/design/themes/responsive/templates/views/checkout/components/promotion_coupon.tpl
index 0dc2dfdf7e2..c18dfdbd9c2 100644
--- a/design/themes/responsive/templates/views/checkout/components/promotion_coupon.tpl
+++ b/design/themes/responsive/templates/views/checkout/components/promotion_coupon.tpl
@@ -1,6 +1,6 @@
{if $cart|fn_display_promotion_input_field}
<div>
- <form class="cm-ajax cm-ajax-force cm-ajax-full-render" name="coupon_code_form{$position}" action="{""|fn_url}" method="post">
+ <form class="cm-ajax cm-ajax-force cm-ajax-full-render" name="coupon_code_form{$position}" action="{""|fn_url}" method="post" id="coupon_code_form{$position}">
<input type="hidden" name="result_ids" value="checkout*,cart_status*,cart_items,payment-methods,litecheckout_form" />
<input type="hidden" name="redirect_url" value="{$config.current_url}" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment