Woocommerce定制运费价格含税

时间:2017-03-28 09:21:24

标签: php wordpress woocommerce shipping

我有自定义送货方式添加计算运费,并使用以下代码

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,
                    'calc_tax' => 'per_order'
                );
                // Register the rate
                $this->add_rate( $rate );
                wc_clear_notices();
                }

                  } // if zone data

                    }
            }
            else { 
                $rate = array(
                    'id' => $this->id,
                    'label' => 'Delivery',
                    'cost' => 0,
                    'calc_tax' => 'per_order'
                );
                // Register the rate
                $this->add_rate( $rate );
                //wc_clear_notices();                   
                //wc_add_notice( 'Please enter zipcode to calculate the shipping', 'error' );       

                }   
                } // calculate shipping

但在前端它增加税额除税。对于产品税工作正常,但由于运费是独家的价格,我想包括税的运费。

0 个答案:

没有答案