Closed mdfathi99 closed 1 year ago
It looks like It was working but after reloading. So I had a fix. After Selecting the Delivery location As "Location 1", I had a set up in the backend a 1$ shipping fee for "Location 1". But when I was selecting "Location 1" the delivery charge was not changing. So I used this script to reload the cart when I was clicking on other field.
I used WPCode/Code Snippet Plugin to insert the code
/**
* Change shipping field attributes to trigger checkout update.
*/
function fluidcheckout_change_shipping_address_fields_args( $fields ) {
if ( array_key_exists( 'shipping_state', $fields ) ) { $fields[ 'shipping_state' ][ 'class' ][] = 'update_totals_on_change'; }
if ( array_key_exists( 'shipping_city', $fields ) ) { $fields[ 'shipping_city' ][ 'class' ][] = 'update_totals_on_change'; }
if ( array_key_exists( 'shipping_postcode', $fields ) ) { $fields[ 'shipping_postcode' ][ 'class' ][] = 'update_totals_on_change'; }
return $fields;
}
add_filter( 'woocommerce_shipping_fields', 'fluidcheckout_change_shipping_address_fields_args', 300 );
/**
* Change billing field attributes to trigger checkout update.
*/
function fluidcheckout_change_billing_address_fields_args( $fields ) {
if ( array_key_exists( 'billing_state', $fields ) ) { $fields[ 'billing_state' ][ 'class' ][] = 'update_totals_on_change'; }
if ( array_key_exists( 'billing_city', $fields ) ) { $fields[ 'billing_city' ][ 'class' ][] = 'update_totals_on_change'; }
if ( array_key_exists( 'billing_postcode', $fields ) ) { $fields[ 'billing_postcode' ][ 'class' ][] = 'update_totals_on_change'; }
return $fields;
}
add_filter( 'woocommerce_billing_fields', 'fluidcheckout_change_billing_address_fields_args', 300 );
Insertion should be Auto Insert
& Location should be Run Everywere
In normal woocommerce you can set delivery charge based on City, but after installing the pluggin this method isn't working. What to do?