0

对于我的一个客户,我正在使用 WooCommerce 开发一个网上商店。

当订单总重量超过 30 公斤和/或送货地址不是荷兰时,用户需要联系网店老板了解运费。

对于第一个条件(订单超过 30 公斤),我在我的 functions.php 中创建了以下内容,以在购物车和结帐页面显示通知消息:

add_action('wp_enqueue_scripts', 'enqueue_childtheme_scripts', 1000);

// Max weight check
add_action('woocommerce_check_cart_items','check_cart_weight');

function check_cart_weight(){
    global $woocommerce;
    $weight = $woocommerce->cart->cart_contents_weight;
    if( $weight > 30 && ICL_LANGUAGE_CODE=='en' ){
        wc_add_notice( sprintf( __( 'The total weight of your order is %sKg. Please <a href="http://www.link-to-webshop.nl/en/contact/">contact us</a> for shipping rates for orders above 30Kg.', 'woocommerce' ), $weight ) );
    }
    elseif( $weight > 30 && ICL_LANGUAGE_CODE=='nl' ){
        wc_add_notice( sprintf( __( 'Het totale gewicht van uw bestelling bedraagt %sKg. Voor de verzendkosten van bestellingen van boven de 30Kg dient u <a href="http://www.link-to-webshop.nl/contact/">contact</a> met ons op te nemen.', 'woocommerce' ), $weight ) );
    }
}

所以这就像一个魅力。但问题是,当用户选择运送到荷兰以外的任何其他国家/地区时,我不知道如何在购物车和结帐页面创建另一条通知消息。

有谁知道如何实现这一目标?

4

1 回答 1

0

你试过插件吗?

https://wordpress.org/plugins/oik-weightcountry-shipping/

woothemes 有一个官方插件,但价格昂贵

http://www.woothemes.com/products/woocommerce-conditional-shipping-and-payments/

于 2015-06-03T09:57:40.290 回答