Special Woocommerce Shipping Price Including Tax
I have a custom shipping method to add shipping calculation and using the below code
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
But at the front end, adding the tax amount excludes tax. For goods, tax works fine, but for shipping is the exclusive price I want including shipping for tax.
+3
source to share
No one has answered this question yet
Check out similar questions: