I need to add/update shipping cost to the cart widget based on address field entered/changed.

enter image description here

Is there any Woocommerce hook which would let me update 'Local Delivery' value after address field is changed/entered?

I manipulate the address and based on address I add custom shipping cost.


There is a similar question on StackOverflow, check the answer there. Hope this will help you.

Here is the code you can use:

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );

function custom_override_checkout_fields( $fields ) {

    $fields['shipping']['custom_field'] = array(
        'label' => 'Custom field',
        'required' => 1,
        'class' => array ('address-field', 'update_totals_on_change' )

    return $fields;

Basically what is important here is the class 'update_totals_on_change'. From here Woocommerce will handle everything by its functionality.

| improve this answer | |
  • Much better, this is now a proper answer. Removed my downvote :-) – Pieter Goosen Jun 15 '15 at 13:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.