---
title: "How do you force the order total to update in WooCommerce?"
description: "Barely a few minutes ago Raquel, a reader and follower of our website, told us in a comment about a problem she has come across in WooCommerce when using our plugin WC - APG Weight Shipping. Specifically, the error means"
url: https://artprojectgroup.com/how-to-force-the-order-total-to-update-in-woocommerce
date: 2014-01-27
modified: 2023-02-11
author: "Art Project Group"
image: https://artprojectgroup.com/wp-content/uploads/2023/04/woocommerce-blog.webp
categories: ["Tutorials"]
tags: ["E-commerce", "PHP", "WC - APG Weight Shipping", "WooCommerce", "WordPress"]
type: post
lang: en-US
---

# How do you force the order total to update in WooCommerce?

Barely a few minutes ago Raquel, a reader and follower of our website, told us in a [comment](/woocommerce-plugins/wc-apg-weight-shipping#comment-258) about a problem she has come across in WooCommerce when using our plugin [**WC - APG Weight Shipping**](/woocommerce-plugins/wc-apg-weight-shipping).

Specifically, the error means that on the checkout page the total is not updated according to the shipping address. So the total amount of the order can be wrong. In fact, Raquel states in her second comment that it is only updated when the tick box of the *Ship to billing address* field is clicked.

In reality it is also updated if the *Country* field is changed; what happens is that in her online shop there is no possibility of that, as she sells solely and exclusively to Spain, but we also need the update to be carried out when the state or province is changed and/or when the postcode is changed.

Well then, the solution is very simple; for it we are only going to use part of the code we created for the post [How do you add a NIF or CIF field to WooCommerce 2.0?](/how-to-add-a-nif-or-cif-field-with-validation-to-woocommerce-2-4), which we have also updated with the fix for the error found, so that those who need to add this field have the problem solved too.

We are going to modify, as almost always, the *functions.php* file of our WordPress child theme, into which we are going to enter the following PHP code:

Copy to clipboardSyntax Highlighterfunction fields_that_update_the_total( $fields ) {
$fields[ 'state' ]\[ 'class' ]\[ 0 ] .= ' update_totals_on_change';
$fields[ 'postcode' ]\[ 'class' ]\[ 0 ] .= ' update_totals_on_change';

return $fields;
}
add_filter( 'woocommerce_default_address_fields', 'fields_that_update_the_total' );

And thanks to this simple, straightforward modification we will have fixed the problem.

We hope that both Raquel and all of you who have suffered from this problem find this small modification useful. We look forward to your comments.
