Ecommerce Shopify WordPress Discussion

Woocommerce shipment add tax rate programmatically

For my Woocommerce shop I try to set a specific tax rate. I have two tax rates in my shop: 9% (low rate) and 21% (high rate). Some products have the low rate and other the high rate. My problem: If the customer buy a product with the low rate the same tax is calculated for the shipment. If the customer buy a product with the high rate the same tax is calculated for the shipment. But if the customer bought multiple products with different tax rates the lowest tax rate is calculated for the shipment. What I want: If the customer bought multiple products with different tax rates the highest tax rate must be calculated for the shipment. I tried add_filter('woocommerce_checkout_create_order', function($order){ $activeShipping = $order->get_items('shipping'); foreach($activeShipping as $shipment){ $shipment->set_total('10'); $shipment->calculate_taxes('hoog'); } $order->calculate_totals(); }, 10, 1); The code triggered the shipping costs but not the tax rate. Who can help me out with this?
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.