Hi everyone!
I was trying to modify the default registration form, cause i need more information about my customers, but it’s almost impossible without apps.
So, after clicking on Submit on registration, the user will be redirected to the URL of the address in the account area.
I tried with something like this:
<button>
{{ 'customer.register.submit' | t }}<a href=""></a>
</button>
<script>
(function() {
var REDIRECT_PATH = '/account/addresses';
var selector = '#create_customer, form[action$="/account"][method="post"]',
$form = document.querySelectorAll(selector)[0];
if ($form) {
$redirect = document.createElement('input');
$redirect.setAttribute('name', 'return_to');
$redirect.setAttribute('type', 'hidden');
$redirect.value = REDIRECT_PATH;
$form.appendChild($redirect);
}
})();
</script>
{% if form.posted_successfully? %}
<h1>COMPLIMENTI, CONTINUA A NAVIGARE</h1>
{% else %}
<script>
(function() {
var REDIRECT_PATH = '/account/addresses';
var selector = '#create_customer, form[action$="/account"][method="post"]',
$form = document.querySelectorAll(selector)[0];
if ($form) {
$redirect = document.createElement('input');
$redirect.setAttribute('name', 'return_to');
$redirect.setAttribute('type', 'hidden');
$redirect.value = REDIRECT_PATH;
$form.appendChild($redirect);
}
})();
</script>
{% endif %}
Can i “force” the customers to stay on this page until the address form is filled?
Thank you so much in advance!