Probably you already found a better way to do this since this question is quite old, but so far I could only make it work by getting the price difference manually and then using the method set_total from the order object:
$order = new \WC_Order(2051);
$diff = 0;
foreach ($order->get_items('shipping') as $key => $item) {
wc_update_order_item_meta($key,'cost',0);
wc_update_order_item_meta($key,'total_tax',0);
wc_update_order_item_meta($key,'taxes',[]);
$diff += $item->get_total();
}
$newTotal = $order->calculate_totals() - $diff;
$order->set_total($newTotal);
$order->save();
I will post this here because maybe it could be useful for someone. If you see this and you found a better / cleaner way to solve this I would like to see it :-).
Related Posts:
- WooCommerce: How to edit the get_price_html
- Get woocommerce product price by id [closed]
- Woocommerce: How to remove page-title at the home/shop page but not category pages
- Hidden woocommerce products still showing up in search results [closed]
- Pass custom Checkout field value to Stripe gateway in WooCommerce
- Preventing WooCommerce email sending only on particular conditions
- Woocommerce view order link in customer emails
- Set a specific default stock quantity on all WooCommerce new products
- Shipping Location based on IP (Geolocation)
- Is there a Woocommerce hook that fires when applying a coupon but before checking if it’s valid?
- How to search Woo Commerce products with punctuation in title?
- How to unhook a function in Woocommerce Template?
- woocommerce “publish “”product”” webhook
- Disable Woocommerce product tags display by alphabetical order
- Hide Price on one specific Woocommerce Single Product page [closed]
- Woocommerce and Pricing deals plugin total price update with AJAX
- Send a value to woocommerce with a button type submit
- Breadcrumbs on Product Page Always Show Wrong Product [closed]
- Image is not displayed in overridden woocommerce email
- Modify SKU for display on product page
- Permalinks contain unwanted space resulting in broken links
- WP_Query with meta_query for children
- WooCommerce Display Digital Download Files Type and Size
- woo commerce get all orders item given category
- Add Stripe Connect data to wc_stripe_payment_request
- WooCommerce get default shipping rate & conditions
- Using WooCommerce for payments only?
- Woo commerce+ Stripe – How to associate one account per currency [closed]
- WooCommerce – Stock in Decimals, Using Quantity Intervals with Unique Prices [closed]
- Adding product info for printing to custom Woocommerce Product Display tab [closed]
- WooCommerce Cart Link based on Cookie Values
- Woocommerce is_shop not on page slug? [closed]
- WooCommerce – Trigger Checkout Form Validation
- Debugging why featured images have stopped showing in WooCommerce on the homepage [closed]
- Add shipping address to Woocommerce order emails [closed]
- woocommerce list product by id
- A function to add arguments to a taxonomy
- add sub subpage endpoint to woocommerce plugin my-account section
- Show Content On below single product with specific category
- How to change a WooCommerce Subscription Deposit and Monthly Payment? [closed]
- how to change the “return to shop” button text? [closed]
- how to scrolling image on single product page
- How to display WooCommerce product tag names on home and category pages
- Specifically Link To the “Leave a review” part of product page? [closed]
- Problem while adding the variable product woocommerce
- How do I create a filter to hide the One Click Accessibility plugin button in WordPress?
- customers are not showing up in woocommerce
- Woocommerce pre_get_posts query variation meta data not working
- Can’t hide product attributes with css on WooCommerce Product Page
- Updating product image
- Split in 2 columns add to cart button and variable forms
- Woocomerce Edit source code of form in wordpress
- Single Product Page as a Popup
- Woocommerce to get restaurant table numbers in the checkout fields from the url
- Woocommerce – Change order of products in Confirmed Order
- echo product parent category
- How to edit wc_get_template_part for archive products
- Switch to user link shortcode
- UX Builder not loading for product description edits
- I need help with storefront theme shop page
- Display WooCommerce product attribute on shop page
- How to get product category ID based on post?
- Jump to Footer On Scroll – Woocommerce Pages Phones Only
- WordPress Development Workflow
- Woocommerce redirection product_name -> product_cat/product_name
- Woocommerce shop page not showing all products
- Custom account page that accepts a query parameter
- Custom WooCommerce template for product
- Checkout fr Woocommerce – load default WooCommerce checkout template on the fly
- Loop Through Current Woocommerce Product Categories Sub Categories
- why my price is not showing while adding new product?
- How to send Woocommerce Customer Details (Name, Email and Phone Number) to Admin upon signup
- Sending billing details via POST request to an API
- Remove username and account password field from checkout page
- How to send an invoice with details to the customers
- Tax exclusive if coupon applied else tax inclusive in items
- WooCommerce Registration, Sync User, Billing and Shipping info
- HTTP Error when uploading pictures and problem with the size of images
- add_rewrite_rule() returns 404 page
- How to change “add to basket” button text in WooCommerce based on product category?
- Select all product woocommerce
- Woocommerce REST API: creating variations
- Woocommerce Setup not completing
- How to check which shortcode is using my template?
- woocommerce: when adding or removing items to cart , it takes cart a few seconds to read changes?
- When to use a child theme for WooCommerce Storefront?
- WooCommerce: Bulk Quantity in Cart
- WooCommerce – Adding Product Attributes to CSV Export
- Unable to enocde the result of wc_get_products
- Remove Span Class From Woocommerce Price
- Woocommerce shows empty columns [closed]
- Product atributes in title of order (not in description)
- How to create custome pdf file of my invioice in wordpress
- How to get sub items of parent menu item?
- WordPress and WooCommerce How to Assign Attribute Based Pricing
- Notice: Trying to get property of non-object in bodycenter [closed]
- WooCommerce remove billing detail completly
- unable to get product by category only getting product added lastly
- Storefront Child Theme show product attribute [closed]
- Hide price, “add to cart” button and show message “Please log in to shop” [closed]