Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.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
Php 在WooCommerce中设置总订单的最小体积和重量_Php_Wordpress_Woocommerce - Fatal编程技术网

Php 在WooCommerce中设置总订单的最小体积和重量

Php 在WooCommerce中设置总订单的最小体积和重量,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,第一:请原谅我在编码方面的0知识。我正在努力学习。 问题:一些货运插件需要最小重量和/或体积,或者它们不会将信息发送给快递员,您需要手动执行 我认为我需要检索长度、高度和宽度,并检查它们是否都符合要求。如果他们没有,那么我想增加最低要求 我搜索了如何获取信息,找到了LoicTheAztec在这里写的这封信 这样我就能提取信息了,我猜 因此,要继续,我需要设置条件(以米为单位) if($length

第一:请原谅我在编码方面的0知识。我正在努力学习。 问题:一些货运插件需要最小重量和/或体积,或者它们不会将信息发送给快递员,您需要手动执行

我认为我需要检索长度、高度和宽度,并检查它们是否都符合要求。如果他们没有,那么我想增加最低要求

我搜索了如何获取信息,找到了LoicTheAztec在这里写的这封信

这样我就能提取信息了,我猜

因此,要继续,我需要设置条件(以米为单位)

if($length<0.15){
$length=0.15
}
如果($width<0.11){
$width=0.11
}
如果($高度<0.035){
$height=0.035
}
我走对了吗?我如何从这里继续? 编辑:好的,似乎这还不够,不知何故,我还需要将值发送到签出。我完全卡住了。任何正确方向的指导都是值得赞赏的

foreach(WC()->cart->get_cart() as $cart_item) { 
        // Get an instance of the WC_Product object and cart quantity
        $product = $cart_item['data'];
        $qty     = $cart_item['quantity'];

        // Get product dimensions  
        $length = $product->get_length();
        $width  = $product->get_width();
        $height = $product->get_height();
if ($length < 0.15) {
$length = 0.15
}
if ($width < 0.11) {
$width = 0.11
}
if ($height < 0.035) {
$height = 0.035
}