@@ -44,17 +44,8 @@ function_exists('add_action') or exit();
4444add_action ('woocommerce_after_shipping_rate ' , 'cdek_map_display ' , 10 , 2 );
4545add_action ('woocommerce_checkout_process ' , 'is_pvz_code ' );
4646add_action ('wp_footer ' , 'cdek_add_script_update_shipping_method ' );
47- add_filter ('woocommerce_checkout_fields ' , 'cdek_add_custom_checkout_field ' , 1090 );
47+ add_filter ('woocommerce_checkout_fields ' , 'cdek_checkout_fields ' , 1090 );
4848add_action ('woocommerce_checkout_create_order ' , 'cdek_save_custom_checkout_field_to_order ' , 10 , 2 );
49- function remove_address_field_requirement ($ fields ) {
50- $ fields ['billing ' ]['billing_address_1 ' ]['required ' ] = false ;
51- $ fields ['billing ' ]['billing_address_2 ' ]['required ' ] = false ;
52-
53- return $ fields ;
54- }
55-
56-
57- add_filter ('woocommerce_checkout_fields ' , 'remove_address_field_requirement ' );
5849
5950function getCityCode ($ city_code , $ order ) {
6051 $ api = new CdekApi ();
@@ -250,7 +241,6 @@ function isTariffTypeFromStore($shippingMethodCurrent) {
250241}
251242
252243function cdek_add_update_form_billing ($ fragments ) {
253-
254244 $ checkout = WC ()->checkout ();
255245
256246 parse_str ($ _POST ['post_data ' ], $ fields_values );
@@ -515,7 +505,7 @@ function isCdekShippingMethod($order) {
515505 return $ shippingMethodId === 'official_cdek ' ;
516506}
517507
518- function cdek_add_custom_checkout_field ($ fields ) {
508+ function cdek_checkout_fields ($ fields ) {
519509
520510 $ checkout = WC ()->checkout ();
521511
@@ -535,6 +525,12 @@ function cdek_add_custom_checkout_field($fields) {
535525 $ fields ['billing ' ][$ requiredField ] = $ fields ['billing ' ][$ requiredField ] ?? $ originalFields [$ requiredField ];
536526 }
537527
528+ foreach (['billing_address_1 ' , 'billing_address_2 ' ] as $ field ) {
529+ if (isset ($ fields ['billing ' ][$ field ])) {
530+ $ fields ['billing ' ][$ field ]['required ' ] = false ;
531+ }
532+ }
533+
538534 if (Helper::getActualShippingMethod ()->get_option ('international_mode ' ) === 'yes ' ) {
539535 $ fields ['billing ' ]['passport_series ' ] = [
540536 'label ' => __ ('Серия паспорта ' , 'woocommerce ' ),
0 commit comments