WooC Commerce đặt địa chỉ giao hàng theo chương trình

Ghi chú. Đây là tài liệu cấp Nhà phát triển. Nếu bạn không quen với mã/mẫu và giải quyết xung đột tiềm ẩn, hãy chọn WooExpert hoặc Nhà phát triển để được hỗ trợ. Chúng tôi không thể cung cấp hỗ trợ cho các tùy chỉnh theo Chính sách hỗ trợ của chúng tôi

Nếu bạn không quen với mã và giải quyết các xung đột tiềm ẩn, chúng tôi có một tiện ích mở rộng có thể trợ giúp. Trình chỉnh sửa trường thanh toán WooC Commerce. Việc cài đặt và kích hoạt tiện ích mở rộng này sẽ ghi đè bất kỳ mã nào bên dưới mà bạn cố triển khai; . php khi tiện ích mở rộng được kích hoạt

Mã tùy chỉnh phải được sao chép vào các chức năng của chủ đề con của bạn. tệp php

Các trường thanh toán và vận chuyển để thanh toán được lấy từ loại quốc gia [

$address_fields = apply_filters['woocommerce_shipping_fields', $address_fields];
0] và hàm
$address_fields = apply_filters['woocommerce_shipping_fields', $address_fields];
1. Điều này cho phép WooC Commerce bật/tắt các trường dựa trên vị trí của người dùng

Trước khi trả lại các trường này, WooC Commerce đặt các trường qua bộ lọc. Điều này cho phép chúng được chỉnh sửa bởi các plugin, chủ đề của bên thứ ba và mã tùy chỉnh của riêng bạn

thanh toán

$address_fields = apply_filters['woocommerce_billing_fields', $address_fields];

Đang chuyển hàng

$address_fields = apply_filters['woocommerce_shipping_fields', $address_fields];

Lớp thanh toán thêm các trường đã tải vào mảng 'checkout_fields' của nó, cũng như thêm một số trường khác như "ghi chú đơn hàng"

$this->checkout_fields['billing']    = $woocommerce->countries->get_address_fields[ $this->get_value['billing_country'], 'billing_' ];
$this->checkout_fields['shipping']   = $woocommerce->countries->get_address_fields[ $this->get_value['shipping_country'], 'shipping_' ];
$this->checkout_fields['account']    = array[
    'account_username' => array[
        'type' => 'text',
        'label' => __['Account username', 'woocommerce'],
        'placeholder' => _x['Username', 'placeholder', 'woocommerce']
        ],
    'account_password' => array[
        'type' => 'password',
        'label' => __['Account password', 'woocommerce'],
        'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
        'class' => array['form-row-first']
        ],
    'account_password-2' => array[
        'type' => 'password',
        'label' => __['Account password', 'woocommerce'],
        'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
        'class' => array['form-row-last'],
        'label_class' => array['hidden']
        ]
    ];
$this->checkout_fields['order']  = array[
    'order_comments' => array[
        'type' => 'textarea',
        'class' => array['notes'],
        'label' => __['Order Notes', 'woocommerce'],
        'placeholder' => _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
        ]
    ];

Mảng này cũng được chuyển qua bộ lọc

$this->checkout_fields = apply_filters['woocommerce_checkout_fields', $this->checkout_fields];

Điều đó có nghĩa là bạn có toàn quyền kiểm soát các trường thanh toán – bạn chỉ cần biết cách truy cập chúng

Kết nối với bộ lọc 

$address_fields = apply_filters['woocommerce_shipping_fields', $address_fields];
2 cho phép bạn ghi đè bất kỳ trường nào. Ví dụ: hãy thay đổi trình giữ chỗ trên các trường order_comments. Hiện tại, nó được đặt thành

_x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']

Chúng tôi có thể thay đổi điều này bằng cách thêm một chức năng vào chức năng chủ đề của chúng tôi. tập tin php

________số 8_______

Bạn có thể ghi đè lên các phần khác, chẳng hạn như nhãn

// Hook in
add_filter[ 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ];

// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields[ $fields ] {
     $fields['order']['order_comments']['placeholder'] = 'My new placeholder';
     $fields['order']['order_comments']['label'] = 'My new label';
     return $fields;
}

Hoặc loại bỏ các lĩnh vực

// Hook in
add_filter[ 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ];

// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields[ $fields ] {
     unset[$fields['order']['order_comments']];

     return $fields;
}

Đây là danh sách đầy đủ các trường trong mảng được chuyển đến

$address_fields = apply_filters['woocommerce_shipping_fields', $address_fields];
2

  • thanh toán
    • $address_fields = apply_filters['woocommerce_shipping_fields', $address_fields];
      4
    • $address_fields = apply_filters['woocommerce_shipping_fields', $address_fields];
      5
    • $address_fields = apply_filters['woocommerce_shipping_fields', $address_fields];
      6
    • $address_fields = apply_filters['woocommerce_shipping_fields', $address_fields];
      7
    • $address_fields = apply_filters['woocommerce_shipping_fields', $address_fields];
      8
    • $address_fields = apply_filters['woocommerce_shipping_fields', $address_fields];
      9
    • $this->checkout_fields['billing']    = $woocommerce->countries->get_address_fields[ $this->get_value['billing_country'], 'billing_' ];
      $this->checkout_fields['shipping']   = $woocommerce->countries->get_address_fields[ $this->get_value['shipping_country'], 'shipping_' ];
      $this->checkout_fields['account']    = array[
          'account_username' => array[
              'type' => 'text',
              'label' => __['Account username', 'woocommerce'],
              'placeholder' => _x['Username', 'placeholder', 'woocommerce']
              ],
          'account_password' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-first']
              ],
          'account_password-2' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-last'],
              'label_class' => array['hidden']
              ]
          ];
      $this->checkout_fields['order']  = array[
          'order_comments' => array[
              'type' => 'textarea',
              'class' => array['notes'],
              'label' => __['Order Notes', 'woocommerce'],
              'placeholder' => _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
              ]
          ];
      0
    • $this->checkout_fields['billing']    = $woocommerce->countries->get_address_fields[ $this->get_value['billing_country'], 'billing_' ];
      $this->checkout_fields['shipping']   = $woocommerce->countries->get_address_fields[ $this->get_value['shipping_country'], 'shipping_' ];
      $this->checkout_fields['account']    = array[
          'account_username' => array[
              'type' => 'text',
              'label' => __['Account username', 'woocommerce'],
              'placeholder' => _x['Username', 'placeholder', 'woocommerce']
              ],
          'account_password' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-first']
              ],
          'account_password-2' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-last'],
              'label_class' => array['hidden']
              ]
          ];
      $this->checkout_fields['order']  = array[
          'order_comments' => array[
              'type' => 'textarea',
              'class' => array['notes'],
              'label' => __['Order Notes', 'woocommerce'],
              'placeholder' => _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
              ]
          ];
      1
    • $this->checkout_fields['billing']    = $woocommerce->countries->get_address_fields[ $this->get_value['billing_country'], 'billing_' ];
      $this->checkout_fields['shipping']   = $woocommerce->countries->get_address_fields[ $this->get_value['shipping_country'], 'shipping_' ];
      $this->checkout_fields['account']    = array[
          'account_username' => array[
              'type' => 'text',
              'label' => __['Account username', 'woocommerce'],
              'placeholder' => _x['Username', 'placeholder', 'woocommerce']
              ],
          'account_password' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-first']
              ],
          'account_password-2' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-last'],
              'label_class' => array['hidden']
              ]
          ];
      $this->checkout_fields['order']  = array[
          'order_comments' => array[
              'type' => 'textarea',
              'class' => array['notes'],
              'label' => __['Order Notes', 'woocommerce'],
              'placeholder' => _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
              ]
          ];
      2
    • $this->checkout_fields['billing']    = $woocommerce->countries->get_address_fields[ $this->get_value['billing_country'], 'billing_' ];
      $this->checkout_fields['shipping']   = $woocommerce->countries->get_address_fields[ $this->get_value['shipping_country'], 'shipping_' ];
      $this->checkout_fields['account']    = array[
          'account_username' => array[
              'type' => 'text',
              'label' => __['Account username', 'woocommerce'],
              'placeholder' => _x['Username', 'placeholder', 'woocommerce']
              ],
          'account_password' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-first']
              ],
          'account_password-2' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-last'],
              'label_class' => array['hidden']
              ]
          ];
      $this->checkout_fields['order']  = array[
          'order_comments' => array[
              'type' => 'textarea',
              'class' => array['notes'],
              'label' => __['Order Notes', 'woocommerce'],
              'placeholder' => _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
              ]
          ];
      3
    • $this->checkout_fields['billing']    = $woocommerce->countries->get_address_fields[ $this->get_value['billing_country'], 'billing_' ];
      $this->checkout_fields['shipping']   = $woocommerce->countries->get_address_fields[ $this->get_value['shipping_country'], 'shipping_' ];
      $this->checkout_fields['account']    = array[
          'account_username' => array[
              'type' => 'text',
              'label' => __['Account username', 'woocommerce'],
              'placeholder' => _x['Username', 'placeholder', 'woocommerce']
              ],
          'account_password' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-first']
              ],
          'account_password-2' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-last'],
              'label_class' => array['hidden']
              ]
          ];
      $this->checkout_fields['order']  = array[
          'order_comments' => array[
              'type' => 'textarea',
              'class' => array['notes'],
              'label' => __['Order Notes', 'woocommerce'],
              'placeholder' => _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
              ]
          ];
      4
  • Đang chuyển hàng
    • $this->checkout_fields['billing']    = $woocommerce->countries->get_address_fields[ $this->get_value['billing_country'], 'billing_' ];
      $this->checkout_fields['shipping']   = $woocommerce->countries->get_address_fields[ $this->get_value['shipping_country'], 'shipping_' ];
      $this->checkout_fields['account']    = array[
          'account_username' => array[
              'type' => 'text',
              'label' => __['Account username', 'woocommerce'],
              'placeholder' => _x['Username', 'placeholder', 'woocommerce']
              ],
          'account_password' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-first']
              ],
          'account_password-2' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-last'],
              'label_class' => array['hidden']
              ]
          ];
      $this->checkout_fields['order']  = array[
          'order_comments' => array[
              'type' => 'textarea',
              'class' => array['notes'],
              'label' => __['Order Notes', 'woocommerce'],
              'placeholder' => _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
              ]
          ];
      5
    • $this->checkout_fields['billing']    = $woocommerce->countries->get_address_fields[ $this->get_value['billing_country'], 'billing_' ];
      $this->checkout_fields['shipping']   = $woocommerce->countries->get_address_fields[ $this->get_value['shipping_country'], 'shipping_' ];
      $this->checkout_fields['account']    = array[
          'account_username' => array[
              'type' => 'text',
              'label' => __['Account username', 'woocommerce'],
              'placeholder' => _x['Username', 'placeholder', 'woocommerce']
              ],
          'account_password' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-first']
              ],
          'account_password-2' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-last'],
              'label_class' => array['hidden']
              ]
          ];
      $this->checkout_fields['order']  = array[
          'order_comments' => array[
              'type' => 'textarea',
              'class' => array['notes'],
              'label' => __['Order Notes', 'woocommerce'],
              'placeholder' => _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
              ]
          ];
      6
    • $this->checkout_fields['billing']    = $woocommerce->countries->get_address_fields[ $this->get_value['billing_country'], 'billing_' ];
      $this->checkout_fields['shipping']   = $woocommerce->countries->get_address_fields[ $this->get_value['shipping_country'], 'shipping_' ];
      $this->checkout_fields['account']    = array[
          'account_username' => array[
              'type' => 'text',
              'label' => __['Account username', 'woocommerce'],
              'placeholder' => _x['Username', 'placeholder', 'woocommerce']
              ],
          'account_password' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-first']
              ],
          'account_password-2' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-last'],
              'label_class' => array['hidden']
              ]
          ];
      $this->checkout_fields['order']  = array[
          'order_comments' => array[
              'type' => 'textarea',
              'class' => array['notes'],
              'label' => __['Order Notes', 'woocommerce'],
              'placeholder' => _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
              ]
          ];
      7
    • $this->checkout_fields['billing']    = $woocommerce->countries->get_address_fields[ $this->get_value['billing_country'], 'billing_' ];
      $this->checkout_fields['shipping']   = $woocommerce->countries->get_address_fields[ $this->get_value['shipping_country'], 'shipping_' ];
      $this->checkout_fields['account']    = array[
          'account_username' => array[
              'type' => 'text',
              'label' => __['Account username', 'woocommerce'],
              'placeholder' => _x['Username', 'placeholder', 'woocommerce']
              ],
          'account_password' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-first']
              ],
          'account_password-2' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-last'],
              'label_class' => array['hidden']
              ]
          ];
      $this->checkout_fields['order']  = array[
          'order_comments' => array[
              'type' => 'textarea',
              'class' => array['notes'],
              'label' => __['Order Notes', 'woocommerce'],
              'placeholder' => _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
              ]
          ];
      8
    • $this->checkout_fields['billing']    = $woocommerce->countries->get_address_fields[ $this->get_value['billing_country'], 'billing_' ];
      $this->checkout_fields['shipping']   = $woocommerce->countries->get_address_fields[ $this->get_value['shipping_country'], 'shipping_' ];
      $this->checkout_fields['account']    = array[
          'account_username' => array[
              'type' => 'text',
              'label' => __['Account username', 'woocommerce'],
              'placeholder' => _x['Username', 'placeholder', 'woocommerce']
              ],
          'account_password' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-first']
              ],
          'account_password-2' => array[
              'type' => 'password',
              'label' => __['Account password', 'woocommerce'],
              'placeholder' => _x['Password', 'placeholder', 'woocommerce'],
              'class' => array['form-row-last'],
              'label_class' => array['hidden']
              ]
          ];
      $this->checkout_fields['order']  = array[
          'order_comments' => array[
              'type' => 'textarea',
              'class' => array['notes'],
              'label' => __['Order Notes', 'woocommerce'],
              'placeholder' => _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
              ]
          ];
      9
    • $this->checkout_fields = apply_filters['woocommerce_checkout_fields', $this->checkout_fields];
      0
    • $this->checkout_fields = apply_filters['woocommerce_checkout_fields', $this->checkout_fields];
      1
    • $this->checkout_fields = apply_filters['woocommerce_checkout_fields', $this->checkout_fields];
      2
    • $this->checkout_fields = apply_filters['woocommerce_checkout_fields', $this->checkout_fields];
      3
  • Tài khoản
    • $this->checkout_fields = apply_filters['woocommerce_checkout_fields', $this->checkout_fields];
      4
    • $this->checkout_fields = apply_filters['woocommerce_checkout_fields', $this->checkout_fields];
      5
    • $this->checkout_fields = apply_filters['woocommerce_checkout_fields', $this->checkout_fields];
      6
  • Gọi món
    • $this->checkout_fields = apply_filters['woocommerce_checkout_fields', $this->checkout_fields];
      7

Mỗi trường chứa một mảng thuộc tính

  • $this->checkout_fields = apply_filters['woocommerce_checkout_fields', $this->checkout_fields];
    8 – loại trường [văn bản, vùng văn bản, mật khẩu, chọn]
  • $this->checkout_fields = apply_filters['woocommerce_checkout_fields', $this->checkout_fields];
    9 – nhãn cho trường đầu vào
  • _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
    0 – trình giữ chỗ cho đầu vào
  • _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
    1 – lớp cho đầu vào
  • _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
    2 – đúng hay sai, cho dù trường này có bắt buộc hay không
  • _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
    3 – đúng hay sai, áp dụng cách sửa lỗi rõ ràng cho trường/nhãn
  • _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
    4 – lớp cho phần tử nhãn
  • _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
    5 – đối với hộp chọn, mảng tùy chọn [cặp khóa => giá trị]

Trong những trường hợp cụ thể, bạn cần sử dụng bộ lọc 

_x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
6. Bộ lọc này được áp dụng cho tất cả các trường mặc định thanh toán và vận chuyển

  • _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
    7
  • _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
    8
  • _x['Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce']
    9
  • // Hook in
    add_filter[ 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ];
    
    // Our hooked in function - $fields is passed via the filter!
    function custom_override_checkout_fields[ $fields ] {
         $fields['order']['order_comments']['placeholder'] = 'My new placeholder';
         return $fields;
    }
    0
  • // Hook in
    add_filter[ 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ];
    
    // Our hooked in function - $fields is passed via the filter!
    function custom_override_checkout_fields[ $fields ] {
         $fields['order']['order_comments']['placeholder'] = 'My new placeholder';
         return $fields;
    }
    1
  • // Hook in
    add_filter[ 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ];
    
    // Our hooked in function - $fields is passed via the filter!
    function custom_override_checkout_fields[ $fields ] {
         $fields['order']['order_comments']['placeholder'] = 'My new placeholder';
         return $fields;
    }
    2
  • // Hook in
    add_filter[ 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ];
    
    // Our hooked in function - $fields is passed via the filter!
    function custom_override_checkout_fields[ $fields ] {
         $fields['order']['order_comments']['placeholder'] = 'My new placeholder';
         return $fields;
    }
    3
  • // Hook in
    add_filter[ 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ];
    
    // Our hooked in function - $fields is passed via the filter!
    function custom_override_checkout_fields[ $fields ] {
         $fields['order']['order_comments']['placeholder'] = 'My new placeholder';
         return $fields;
    }
    4
  • // Hook in
    add_filter[ 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ];
    
    // Our hooked in function - $fields is passed via the filter!
    function custom_override_checkout_fields[ $fields ] {
         $fields['order']['order_comments']['placeholder'] = 'My new placeholder';
         return $fields;
    }
    5

Ví dụ: để làm cho trường

// Hook in
add_filter[ 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ];

// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields[ $fields ] {
     $fields['order']['order_comments']['placeholder'] = 'My new placeholder';
     return $fields;
}
1 trở thành tùy chọn

// Hook in
add_filter[ 'woocommerce_default_address_fields' , 'custom_override_default_address_fields' ];

// Our hooked in function - $address_fields is passed via the filter!
function custom_override_default_address_fields[ $address_fields ] {
     $address_fields['address_1']['required'] = false;

     return $address_fields;
}

Nếu bạn đang thêm một trường có loại 'chọn', như đã nêu ở trên, bạn sẽ xác định các cặp khóa/giá trị. Ví dụ

$fields['billing']['your_field']['options'] = array[
  'option_1' => 'Option 1 text',
  'option_2' => 'Option 2 text'
];

Mức độ ưu tiên liên quan đến mã PHP giúp thiết lập khi một đoạn mã — được gọi là hàm — chạy liên quan đến tải trang. Nó được đặt bên trong mỗi chức năng và rất hữu ích khi ghi đè mã hiện có để hiển thị tùy chỉnh

Mã có số cao hơn được đặt làm mức độ ưu tiên sẽ chạy sau mã có số thấp hơn, nghĩa là mã có mức độ ưu tiên 20 sẽ chạy theo mã có mức độ ưu tiên 10

Đối số ưu tiên được đặt trong hàm add_action, sau khi bạn thiết lập hook nào bạn đang kết nối và tên của hàm tùy chỉnh của bạn sẽ là gì

Trong ví dụ bên dưới, văn bản màu xanh lam là tên của hook mà chúng tôi đang sửa đổi, văn bản màu xanh lá cây là tên của chức năng tùy chỉnh và màu đỏ là mức độ ưu tiên mà chúng tôi đã đặt

Trong ví dụ này, mã được đặt để chuyển hướng nút "Quay lại cửa hàng" trong giỏ hàng đến danh mục liệt kê các sản phẩm được bán tại http. //thí dụ. url/danh mục/đặc biệt/

Tệp này chứa văn bản Unicode hai chiều có thể được diễn giải hoặc biên dịch khác với nội dung hiển thị bên dưới. Để xem lại, hãy mở tệp trong trình chỉnh sửa hiển thị các ký tự Unicode bị ẩn. Tìm hiểu thêm về các ký tự Unicode hai chiều

Chủ Đề