第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

根據(jù)所選支付網(wǎng)關(guān)的郵政編碼拒絕 WooCommerce Checkout

根據(jù)所選支付網(wǎng)關(guān)的郵政編碼拒絕 WooCommerce Checkout

PHP
四季花海 2023-06-18 17:58:16
如果且僅當(dāng)客戶(hù)選擇該選項(xiàng)時(shí),我正在嘗試檢查一系列郵政編碼local_pickup。我有一份本地取件選項(xiàng) (local_pickup4) 的副本Home Delivery,我有郵政編碼數(shù)組。如果選擇了本地取貨選項(xiàng),郵政編碼不匹配,預(yù)期結(jié)果是收到錯(cuò)誤通知。add_action('woocommerce_after_checkout_validation', 'zip_code_validator_for_local_home_delivery', 10, 2 );function zip_code_validator_for_local_home_delivery( $data, $error ) {            $del_zones_array = array( 30030, 30032, 30033 );    $chosen_shipping = WC()->session->get( 'chosen_shipping_methods' )[0];    $chosen_shipping = explode(':', $chosen_shipping);    if ( $chosen_shipping[0] == 'local_pickup:4' && !in_array( $data['shipping_postcode'], $del_zones_array ) ) {        $error->add( 'validation', 'We\'re sorry, but this address is outside of our online order delivery area.<br>Please contact us for assistance or choose the local pickup option.' );    }}
查看完整描述

1 回答

?
慕少森

TA貢獻(xiàn)2019條經(jīng)驗(yàn) 獲得超9個(gè)贊

顯示錯(cuò)誤信息需要滿(mǎn)足的條件:(在代碼中作為注釋添加的解釋?zhuān)?/p>

  • 必須選擇當(dāng)?shù)厝∝洝?/p>

  • 郵政編碼不得存在于預(yù)定郵政編碼數(shù)組中

function zip_code_validator_for_local_home_delivery( $data, $error ) {        

    /* Settings */


    // Zones

    $del_zones_array = array( 30030, 30032, 30033 );


    // Shipping method

    $shipping_method = 'local_pickup:4';


    /* End settings */


    // Get chosen shipping method ID

    $chosen_shipping_method_id = WC()->session->get( 'chosen_shipping_methods' )[0];


    // If local pickup is the chosen shipping method && ZIP code NOT in array

    if ( $chosen_shipping_method_id == $shipping_method && !in_array( $data['shipping_postcode'], $del_zones_array ) ) {

        $error->add( 'validation', 'We\'re sorry, but this address is outside of our online order delivery area.<br>Please contact us for assistance or choose the local pickup option.' );

    }

}

add_action('woocommerce_after_checkout_validation', 'zip_code_validator_for_local_home_delivery', 10, 2 );



查看完整回答
反對(duì) 回復(fù) 2023-06-18
  • 1 回答
  • 0 關(guān)注
  • 138 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)