Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Как сделать доставку новой почтой единственной возможной доставкой? #12

Open
squarepusher opened this issue Jan 17, 2019 · 1 comment

Comments

@squarepusher
Copy link

squarepusher commented Jan 17, 2019

В связи с введением зон доставки, я не могу сделать доставку новой почтой, единственной возможной доставкой. Не отображаются поля выбора области, города и отделения.

Как только я включаю одну из дополнительных стандартных доставок, к примеру “самовывоз”, при переключении на доставку новой почтой поля выбора области, города и отделения отображаются и работают корректно.

Помогите решить эту проблему пожалуйста.

@maxsurgai
Copy link

Плагины -> Редактор плагинов -> Выбираем плагин для изменения "Woo Shipping for Nova Poshta" -> assets -> js -> nova-poshta.min.js -> Меняем код на тот, что скину ниже -> Чистим кэш, перезапускаем плагин -> Вуаля, стандартные поля адреса меняются на поля новой почты автоматически

jQuery(document).ready(function(){var o=function(o){var n={},t=o("#billing_nova_poshta_region, #billing_nova_poshta_city, #billing_nova_poshta_warehouse"),i=o("#billing_nova_poshta_region"),e=o("#billing_nova_poshta_city"),a=o("#billing_nova_poshta_warehouse"),r=o("#shipping_nova_poshta_region, #shipping_nova_poshta_city, #shipping_nova_poshta_warehouse"),s=o("#shipping_nova_poshta_region"),c=o("#shipping_nova_poshta_city"),p=o("#shipping_nova_poshta_warehouse"),h=o("#billing_address_1, #billing_address_2, #billing_city, #billing_state, #billing_postcode"),l=o("#shipping_address_1, #shipping_address_2, #shipping_city, #shipping_state, #shipping_postcode"),u=o("input[name^=shipping_method][type=radio]"),d=o("#ship-to-different-address-checkbox"),_=function(){return d.is(":checked")},f=function(){var n=o("input[name^=shipping_method][type=radio]:checked").val();return n||(n=o("input#shipping_method_0").val()),"nova_poshta_shipping_method"===n},v=function(){t.each(function(){o(this).removeAttr("disabled").closest(".form-row").show()}),b()},g=function(){t.each(function(){o(this).attr("disabled","disabled").closest(".form-row").hide()}),m()},m=function(){h.each(function(){o(this).removeAttr("disabled").closest(".form-row").show()})},b=function(){h.each(function(){o(this).attr("disabled","disabled").closest(".form-row").hide()})},y=function(){r.each(function(){o(this).removeAttr("disabled").closest(".form-row").show()}),j()},w=function(){r.each(function(){o(this).attr("disabled","disabled").closest(".form-row").hide()}),N()},N=function(){l.each(function(){o(this).removeAttr("disabled").closest(".form-row").show()})},j=function(){l.each(function(){o(this).attr("disabled","disabled").closest(".form-row").hide()})},x=function(){g(),w()},P=function(){y(),v()},A=function(){o(document).on("change",u,function(){P()}),o(document).on("change",d,function(){P()}),o(document.body).bind("updated_checkout",function(){P()}),P()},S=function(){i.on("change",function(){var n=this.value;o.ajax({url:NovaPoshtaHelper.ajaxUrl,method:"POST",data:{action:NovaPoshtaHelper.getCitiesAction,parent_ref:n},success:function(n){try{var t=JSON.parse(n);e.find("option:not(:first-child)").remove(),o.each(t,function(n,t){e.append(o("<option></option>").attr("value",n).text(t))}),a.find("option:not(:first-child)").remove()}catch(i){console.log("Error. Response from server was: "+n)}},error:function(){console.log("Error.")}})}),e.on("change",function(){var n=this.value;o.ajax({url:NovaPoshtaHelper.ajaxUrl,method:"POST",data:{action:NovaPoshtaHelper.getWarehousesAction,parent_ref:n},success:function(n){try{var t=JSON.parse(n);a.find("option:not(:first-child)").remove(),o.each(t,function(n,t){a.append(o("<option></option>").attr("value",n).text(t))})}catch(i){console.log("Error. Response from server was: "+n)}},error:function(){console.log("Error.")}})}),s.on("change",function(){var n=this.value;o.ajax({url:NovaPoshtaHelper.ajaxUrl,method:"POST",data:{action:NovaPoshtaHelper.getCitiesAction,parent_ref:n},success:function(n){try{var t=JSON.parse(n);c.find("option:not(:first-child)").remove(),o.each(t,function(n,t){c.append(o("<option></option>").attr("value",n).text(t))}),p.find("option:not(:first-child)").remove()}catch(i){console.log("Error. Response from server was: "+n)}},error:function(){console.log("Error.")}})}),c.on("change",function(){var n=this.value;o.ajax({url:NovaPoshtaHelper.ajaxUrl,method:"POST",data:{action:NovaPoshtaHelper.getWarehousesAction,parent_ref:n},success:function(n){try{var t=JSON.parse(n);p.find("option:not(:first-child)").remove(),o.each(t,function(n,t){p.append(o("<option></option>").attr("value",n).text(t))})}catch(i){console.log("Error. Response from server was: "+n)}},error:function(){console.log("Error.")}})})};return n.init=function(){A(),S()},n}(jQuery),n=function(o){var n={},t=function(){var n=o("input[name^=shipping_method][type=radio]:checked").val();return n||(n=o("input#shipping_method_0").val()),"nova_poshta_shipping_method"===n},i=function(){o("#calc_shipping_country").find("option").each(function(){"UA"!==o(this).val()&&o(this).remove()}),o("#calc_shipping_state_field").hide();var n=o('<input type="hidden" id="calc_nova_poshta_shipping_method" value="nova_poshta_shipping_method" name="shipping_method">'),t=o('<input type="hidden" id="calc_nova_poshta_shipping_city" name="calc_nova_poshta_shipping_city">');o("#calc_shipping_city_field").append(t).append(n);var i=o("#calc_shipping_city");i.autocomplete({source:function(o,n){jQuery.ajax({type:"POST",url:NovaPoshtaHelper.ajaxUrl,data:{action:NovaPoshtaHelper.getCitiesByNameSuggestionAction,name:o.term},success:function(o){var t=JSON.parse(o);n(jQuery.map(t,function(o,n){return{label:o,value:n}}))}})},focus:function(o,n){return i.val(n.item.label),!1},select:function(o,n){return i.val(n.item.label),t.val(n.item.value),!1}}),o("form.woocommerce-shipping-calculator").on("submit",function(){if("UA"!==o("#calc_shipping_country").val())return!1})};return n.init=function(){o(document.body).bind("updated_wc_div updated_shipping_method",function(){t()&&i()}),t()&&i()},n}(jQuery);o.init(),n.init()});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants