Redirect 重定向到Shopify上的客户注册时结账

Redirect 重定向到Shopify上的客户注册时结账,redirect,shopify,liquid,Redirect,Shopify,Liquid,在shopify网站上创建帐户后,我想将客户重定向到结帐页面 Shopify提供了在客户登录时重新定向的方法: {% form 'customer_login' %} <input type="hidden" name="checkout_url" value="/checkout"/> {%form'客户\登录名'%} 但对客户注册应用相同的方法时,表单会在成功时重定向到签出,但忽略错误检查: {% form 'create_customer' %} <input

在shopify网站上创建帐户后,我想将客户重定向到结帐页面

Shopify提供了在客户登录时重新定向的方法:

{% form 'customer_login' %}
 <input type="hidden" name="checkout_url" value="/checkout"/>
{%form'客户\登录名'%}
但对客户注册应用相同的方法时,表单会在成功时重定向到签出,但忽略错误检查:

  {% form 'create_customer' %}
 <input type="hidden" name="return_to" value="/checkout" />
{%form'创建客户'%}
这种使用HTML表单而不是液体表单的方法会重定向到签出,但客户未登录,这与在签出之前创建帐户的目的背道而驰:

 <form method='post' action='/checkout' id='create_customer' accept-charset='UTF-8'>
 <input name='form_type' type='hidden' value='create_customer'/>   
 <input name="utf8" type="hidden" value="✓">


在错误检查后,有没有重定向的想法?谢谢

我找到了一个解决方案,它使用AJAX将create customer请求发送到Shopify,然后在成功后将用户重定向到checkout。如果有错误,它们会显示在表单上,而不是像以前建议的解决方案那样自动重定向

HTML:

{% form 'create_customer' %}

<div class ="errors"> </div>
<input type="text" value="" placeholder="First Name" name="customer[first_name]" id="first_name"/>
<input type="text" value="" placeholder="Last Name" name="customer[last_name]" id="last_name"/>
 <input type="email" value="" placeholder="Email" name="customer[email]" id="email" />
 <input type="password" value="" placeholder="Password" name="customer[password]" id="password" />
 <input class="btn" type="submit" value="Create"/>

 {% endform %}

下面的代码将签出url存储在用户浏览器中,然后在用户完成注册过程后将其重定向到该页面。我已经在我拥有的所有5家shopify商店中使用了此解决方案

步骤1:将此代码粘贴到login.liquid文件的底部


var测试=uu st;
setItem('Test',JSON.stringify(Test));

这不适合我。它显示错误状态:429
jQuery(function() {
jQuery('#create_customer').submit(function(event) {
  event.preventDefault();
  var data = jQuery(this).serialize();

 //create new account
  jQuery.post('/account', data)
    .done(function(data){
    var logErrors = jQuery(data).find('.errors').text();

    //if there are errors show them in the html form
    if (logErrors != "" && logErrors != 'undefined'){
        jQuery('#create_customer .errors').html(logErrors);
        jQuery('#create_customer .errors').show();

    //if account creation is successful show checkout page
    }else{
       console.log('success');
      document.location.href = '/checkout';
    }
    }).fail(function(){console.log('error');});
   return false;
}); 
});