A
A
AlexGR072020-07-03 21:55:55
WooCommerce
AlexGR07, 2020-07-03 21:55:55

How to attach a couple of lines of text to the selected shipping method?

Hello.
my task. The appearance of a line of text (if it does change, then in the files), after choosing a delivery method.
For example: free_shipping:1 text appears: Free shipping only within the city where our store is located.
free_shipping:0 text appears: Shipping $2? only within the city where our store is located

Well, display this text to the client. In the class/field "notic-billing" I

planned to use the construction..

add_filter( 'woocommerce_checkout_fields', 'awoohc_override_checkout_fields' );
function awoohc_override_checkout_fields( $fields ) {
// получаем выбранные метод доставки
   $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
   // проверяем текущий метод и добавляем текст
   if ( 'free_shipping:1' === $chosen_methods[0] ) {

      set( $fields['billing']['notic-billing'] = "Вы заказываете бесплатную доставку в пределах досягаемости магазина филиала";
   )
   return $fields;
   }
}


so far it hasn't worked

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question