Reorder Woocommerce checkout fields

后端 未结 5 1208
礼貌的吻别
礼貌的吻别 2020-12-15 00:25

I am trying to reorder the billing fields on the checkout page but everything I tried so far is not working.

Here is the snippet I am currently trying:



        
5条回答
  •  盖世英雄少女心
    2020-12-15 01:14

    The ordering(sorting) works on address-i18n.min.js not in php code.

    In my case, I did something wrong on my js code. So, the ordering didn't work well( javascript stop there ).

    Please check dev console and js error.

    And this is php code which change only priority.

    function rpf_edit_default_address_fields($fields) {
    
      /* ------ reordering ------ */
      $fields['country']['priority'] = 10;
      $fields['first_name']['priority'] = 20;
      $fields['last_name']['priority'] = 30;
      $fields['address_1']['priority'] = 40;
      $fields['address_2']['priority'] = 50;
      $fields['city']['priority'] = 60;
      $fields['state']['priority'] = 70;
      $fields['postcode']['priority'] = 80;
    
      return $fields;
    }
    add_filter( 'woocommerce_default_address_fields', 'rpf_edit_default_address_fields', 100, 1 );
    

    Good Luck!

提交回复
热议问题