Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/430.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当用户填写签出表单时,使用Ajax抛出错误消息_Javascript_Php_Ajax_Woocommerce - Fatal编程技术网

Javascript 当用户填写签出表单时,使用Ajax抛出错误消息

Javascript 当用户填写签出表单时,使用Ajax抛出错误消息,javascript,php,ajax,woocommerce,Javascript,Php,Ajax,Woocommerce,我正在开发一个商业商店。我有特定邮政编码的最低订购量。 如何在用户填写结帐表单时显示错误消息,尤其是在键入邮政编码时显示邮政编码字段,然后向用户显示邮政编码未达到最低订单金额的错误消息。 目前,当用户最后单击PlaceOrder按钮时,我会抛出这些消息 根据答案,这是我的代码: add_action( 'woocommerce_checkout_process' , 'required_min_cart_subtotal_amount'); // Only run in the Cart or

我正在开发一个商业商店。我有特定邮政编码的最低订购量。 如何在用户填写结帐表单时显示错误消息,尤其是在键入邮政编码时显示邮政编码字段,然后向用户显示邮政编码未达到最低订单金额的错误消息。 目前,当用户最后单击PlaceOrder按钮时,我会抛出这些消息

根据答案,这是我的代码:

add_action( 'woocommerce_checkout_process' , 'required_min_cart_subtotal_amount');

// Only run in the Cart or Checkout pages
function required_min_cart_subtotal_amount() {
    
    if( is_checkout()) {
        global $woocommerce;

        // Set the minimum order amount and shipping zone before checking out
        $county1    = array(69214);
                
        // Defining var total amount      
        $cart_tot_order = WC()->cart->total;
        
        if( $cart_tot_order < 8 && in_array( WC()->customer->get_shipping_postcode(), $county1 )  ) {
            // Display error message
             wc_add_notice( sprintf( '<strong>Eine Mindestbestellmenge von $% s ist erforderlich, um an Ihre Adresse zu liefern.</strong>' 
                . '<br />Aktueller Auftrag: $%s.',
                8,
                $cart_tot_order ),
            'error' );
            
        }}
add_action('woocommerce_checkout_process'、'required_min_cart_subtotal_amount');
//仅在购物车或结帐页面中运行
所需功能\u最小\u购物车\u小计\u金额(){
if(is_checkout()){
全球商业;
//退房前设置最低订单金额和配送区域
$county1=数组(69214);
//定义var总额
$cart_tot_order=WC()->cart->total;
如果($cart_tot_order<8&&in_数组(WC()->customer->get_shipping_postcode(),$county1)){
//显示错误消息
wc_添加_通知(sprintf(“这是我的地址,$%s,是我的地址)。”
“
Aktueller Auftrag:$%s.”, 8. $cart_tot_订单), “错误”); }}
抱歉,但“我想”不是一个问题Yeah@LoicTheAztec,但我跳过了购物车页面,当用户在结帐页面键入邮政编码时,如何实现这一点,它涉及订单总数和邮政编码…我不知道您是否遇到了问题Yeah,这就是为什么我想以这种方式实现错误消息。。。。。