php [不允许PO BOX运输]禁止在WooCommerce中运送邮政信箱

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php [不允许PO BOX运输]禁止在WooCommerce中运送邮政信箱相关的知识,希望对你有一定的参考价值。

add_action('woocommerce_after_checkout_validation', 'deny_pobox_postcode');

function deny_pobox_postcode( $posted ) {
  global $woocommerce;

  $address  = ( isset( $posted['shipping_address_1'] ) ) ? $posted['shipping_address_1'] : $posted['billing_address_1'];
  $postcode = ( isset( $posted['shipping_postcode'] ) ) ? $posted['shipping_postcode'] : $posted['billing_postcode'];

  $replace  = array(" ", ".", ",");
  $address  = strtolower( str_replace( $replace, '', $address ) );
  $postcode = strtolower( str_replace( $replace, '', $postcode ) );

  if ( strstr( $address, 'pobox' ) || strstr( $postcode, 'pobox' ) ) {
    wc_add_notice( sprintf( __( "Sorry, we cannot ship to PO BOX addresses.") ) ,'error' );
  }
}

以上是关于php [不允许PO BOX运输]禁止在WooCommerce中运送邮政信箱的主要内容,如果未能解决你的问题,请参考以下文章

php [不允许PO BOX运输]禁止在WooCommerce中运送邮政信箱

在 WooCommerce 购物车页面中的每个产品下方添加运输类别

sql PO(运输)跟踪号码(来自ASN)

sql PO(运输)跟踪号码(来自ASN)

sql PO(运输)跟踪号码(来自ASN)

sql PO(运输)跟踪号码(来自ASN)