久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使 Woocommerce 結帳中的結帳字段成為必需

Make checkout fields required in Woocommerce checkout(使 Woocommerce 結帳中的結帳字段成為必需)
本文介紹了使 Woocommerce 結帳中的結帳字段成為必需的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

出于某種原因,帳單地址中的所有字段都標記為可選 - 客戶將帳單地址字段留空,然后他們的付款被拒絕(Square,我們的付款處理方).

For some reason, all the fields in Billing Address are marked as optional - customers are leaving the billing address fields blank and then their payments are being rejected (by Square, who is our payment processor).

我找不到任何地方將這些字段設為必填字段,也無法弄清楚為什么它們在任何情況下都會被標記為可選.

I cannot find anywhere to make these fields required, and cannot figure out why they would be marked as optional in any case.

有人能指出我正確的方向嗎?

Can someone point me in the right direction?

更新

我什至嘗試過以下方法:

I've even tried the following:

add_filter('woocommerce_billing_fields', 'force_billing_fields', 1000, 1);
function force_billing_fields($fields) {
  $fields['billing_first_name']['required'] = true;
  $fields['billing_last_name']['required'] = true;
  $fields['billing_address_1']['required'] = true;
  $fields['billing_city']['required'] = true;
  $fields['billing_postcode']['required'] = true;
  $fields['billing_country']['required'] = true;
  $fields['billing_state']['required'] = true;
  $fields['billing_email']['required'] = true;
  $fields['billing_phone']['required'] = true;

  return $fields;
}

它們仍然被標記為可選,除了帳單電話和國家/地區(qū)現在被標記為必需.但其余的仍然是可選的.

And they're still marked as optional, except the billing phone and country are now marked as required. But the rest are still optional.

推薦答案

如果你沒有像我的評論中解釋的那樣發(fā)現有罪,你可以做的是使用以下(在此處使用最高掛鉤優(yōu)先級,如果其他一些代碼已經在使用這些鉤子):

What you can do if you don't find the guilty as explained on my comment is to use the following (using here a highest hook priority if some other code is already using those hooks):

add_filter( 'woocommerce_default_address_fields', 'customising_checkout_fields', 1000, 1 );
function customising_checkout_fields( $address_fields ) {
    $address_fields['first_name']['required'] = true;
    $address_fields['last_name']['required'] = true;
    $address_fields['company']['required'] = true;
    $address_fields['country']['required'] = true;
    $address_fields['city']['required'] = true;
    $address_fields['state']['required'] = true;
    $address_fields['postcode']['required'] = true;

    return $address_fields;
}

代碼位于活動子主題(或活動主題)的 function.php 文件中.經測試有效.

Code goes in function.php file of your active child theme (or active theme). tested and works.

對于計費電話和電子郵件,您可以嘗試

For billing phone and email you can try

add_filter('woocommerce_billing_fields', 'custom_billing_fields', 1000, 1);
function custom_billing_fields( $fields ) {
    $fields['billing_email']['required'] = true;
    $fields['billing_phone']['required'] = true;

    return $fields;
}

add_filter('woocommerce_checkout_fields', 'custom_billing_fields', 1000, 1);
function custom_billing_fields( $fields ) {
    $fields['billing']['billing_email']['required'] = true;
    $fields['billing']['billing_phone']['required'] = true;

    return $fields;
}

這篇關于使 Woocommerce 結帳中的結帳字段成為必需的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯(lián)網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產品的總訂單數)
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 黑人巨大精品欧美一区二区一视频 | 中文字幕av一区 | 自拍 亚洲 欧美 老师 丝袜 | 成人欧美一区二区三区视频xxx | 国产亚洲精品久久19p | 最近日韩中文字幕 | 欧美黄色一区 | 成人在线观看免费视频 | 精品亚洲一区二区三区 | 在线欧美亚洲 | 欧美一区二区三区四区视频 | 日本精品一区 | 亚洲视频1区 | 男女久久久 | 国产精品18hdxxxⅹ在线 | 国产精品一区二 | 亚洲小视频 | 亚洲黄色片免费观看 | 成人久久久 | 国产一区二区精品在线 | 亚洲视频免费在线 | 欧美精品99 | 综合色站导航 | 久久精品免费观看 | 国产日韩一区二区 | 国产精品美女久久久久久免费 | 韩国av一区二区 | 国精久久| 欧美精品一区久久 | 台湾佬伊人 | 激情91 | 中文字幕亚洲欧美日韩在线不卡 | 欧美精品综合 | www.婷婷 | 久久国产精品-国产精品 | 欧美久久久久久 | 四虎影院一区二区 | 人人草人人干 | 日韩一区二区三区av | 一区二区三区中文字幕 | 日韩免费看视频 |