Criar custom field no checkout

@merceloki é possivel sim, voce tem que adicionar centro do checkout6.js e uma linha no css para mostrar ele. Dentro do MD é necessário que a entidade possua os campos ‘birthDate’ como leitura publica e ‘email’ como filtro público.Arquivos que precisa subir no checkout:

checkout5-custom.css (268,Bytes)

#birthDate.input-small {
  width:  150px;
  padding: 0 10px;
    border: 1px solid #ccc;
    box-shadow: none;
    border-radius: 2px;
    font-size: 14px;
    color: #000;
    line-height: 33px;
    height: 36px;
    font-family: 'Open Sans', sans-serif;
}

checkout6-custom.js (2,1,KB)

  $(window).on("orderFormUpdated.vtex", function(e,_orderForm){
    birthDate = $("#birthDate");
  	if(birthDate.val().length == 0){
      var _email = ((_orderForm.clientProfileData != null) ? _orderForm.clientProfileData.email : $("#client-email").val());
      	if(_email.length == 0) _email = $("#client-pre-email").val();
      if(_email.length > 0){
          $.ajax({
          url: "https://api.vtexcrm.com.br/" + vtex.accountName + "/dataentities/CL/search/?_fields=birthDate&_where=email=" + _email,
          dataType: "json",
          type: "GET",
          crossDomain: !0,
          headers: {
            Accept: "application/vnd.vtex.ds.v10 json",
            "Content-Type": "application/json; charset=utf-8"
          },
            success: function(o) {
              if(o.length > 0) {
                birthDate.val(o[0].birthDate.split("T")[0]);
              } 
              console.log("get birthDate")
            },
          fail: function(e){console.log(e);console.log("erro get birthDate");}
        })
      }
    }
  });
}),
$(window).on("componentDone.vtex", function() {
  birthDate = $("#birthDate");
  if(birthDate.length>0 && vtexjs.checkout.orderForm.clientProfileData != null && birthDate.val().length > 0){
    $.ajax({
      url: "https://api.vtexcrm.com.br/" + vtex.accountName + "/dataentities/CL/documents/",
      dataType: "json",
      type: "PATCH",
      crossDomain: !0,
      data: JSON.stringify({email: vtexjs.checkout.orderForm.clientProfileData.email, birthDate: birthDate.val()}),
      headers: {
        Accept: "application/vnd.vtex.ds.v10 json",
        "Content-Type": "application/json; charset=utf-8"
      },
      success: function(e) {console.log(e), console.log("salvei birthDate")},
      fail: function(e){console.log(e);console.log("erro patch birthDate");}
    })
  }
})
1 Like