小编Vip*_*pul的帖子

Woocommerce定制运输价格含税

我有添加的自定义运输方法来计算运输,并使用以下代码

public function calculate_shipping( $package ) {
                $postcode_data = $package['destination']['postcode'];
                if(!empty($postcode_data)){
                $weight = 0;    
                $zone_data = checkzone($postcode_data);
                if(isset($package['destination']['postcode'])){
                if(!empty($zone_data)){     
                $weight = WC()->cart->cart_contents_weight;  // get cart total weight   
                if($weight <= 100){
                    $weight_range = ceil($weight / 10 );
                }
                elseif(($weight > 100 ) && ($weight < 150) ){
                    $weight_range = 11 ; 
                }
                if($weight >= 150) 
                {
                    $weight_range = 12 ; 
                }

                $pricing = getpricing($zone_data , $weight_range); 


                if($pricing > 0){                   
                $rate = array(
                    'id' => $this->id,
                    'label' => 'Delivery',
                    'cost' => $pricing, …
Run Code Online (Sandbox Code Playgroud)

php wordpress shipping woocommerce

5
推荐指数
0
解决办法
363
查看次数

标签 统计

php ×1

shipping ×1

woocommerce ×1

wordpress ×1