FROM CACHE - en_header

Inconveniences when adding notes to the order from the checkout page

juceisk
Excursionist
17 0 2

Hello everyone, I am trying to add a note to the orders of my store, the content of the note is a json but I see that not all the orders are added the note, what could be happening? Thank you in advance for your help.
The code I use is the following:

 

<script>

(function ($) {
$(document).on("page:load page:change", function () {
if (Shopify.Checkout.step === 'payment_method') {
var Origen = 'WEB';
{% if customer.tags contains 'EMBAJADOR' %} Origen = 'EMBAJADOR';{% endif %}
setObjectNote(Origen);
}
});


function setObjectNote(origen){

var ObjNote = {}
var myInput = document.getElementById("checkout_billing_note");

if (myInput == null){
var nota= '<div data-address-field="note" data-autocomplete-field-container="true" style="display: none;" class="field field--optional"><div class="field__input-wrapper"><label class="field__label field__label--visible" for="checkout_billing_note">Origen (opcional)</label><input placeholder="Origen (opcional)" autocomplete="billing note" autocorrect="off" data-backup="note" class="field__input" size="30" type="text" name="checkout[note]" id="checkout_billing_note"></div></div>'
$("form[data-payment-form='']").append(nota)
myInput = document.getElementById("checkout_billing_note");
}else
{
myInput.value = "";
}

ObjNote.Origen = origen;
myInput.value = JSON.stringify(ObjNote);

}

}) (Checkout.$);

</script>

Replies 0 (0)