Edit woocommerce shipping calculator

Active3 hr before
Viewed126 times

4 Answers


Meta Stack Overflow ,I have added custom cities to Woocommerce checkout and each city represents a rate. However, I would like to have a dropdown of cities in the shipping calculator as I have done with the checkout page., Stack Overflow Public questions & answers , Stack Overflow help chat

To enable the city field in the shipping calculator you need to use:

add_filter('woocommerce_shipping_calculator_enable_city', '__return_true');

In the Woocommerce template cart/shipping-calculator.php, you will replace:

        <p class="form-row form-row-wide" id="calc_shipping_city_field">
           <input type="text" class="input-text" value="<?php echo esc_attr( WC()->customer->get_shipping_city() ); ?>" placeholder="<?php esc_attr_e( 'City', 'woocommerce' ); ?>" name="calc_shipping_city" id="calc_shipping_city" />

By this code instead:

        <p class="form-row form-row-wide" id="calc_shipping_city_field">
                // HERE <===== define your array of cities
                $cities = array('Paris','Lyon','Marseille','Nice');

                $current_city = esc_attr( WC()->customer->get_shipping_city() );
           <select name="calc_shipping_city" id="calc_shipping_city">
              <option value=""><?php _e( 'Select a City&hellip;', 'woocommerce' ); ?></option>
              <?php foreach( $cities as $city ):
                echo '<option value="'.$city.'" '.selected( $current_city, $city ).'>'.$city.'</option>';
                endforeach; ?>
load more v

Support » Plugin: WooCommerce » moidfy the shipping calculator fields,The topic ‘moidfy the shipping calculator fields’ is closed to new replies.,Hello there, This can be done by editing the template woocommerce/templates/cart/shipping-calculator.php.,About WordPressAbout WordPressWordPress.orgDocumentationSupportFeedback

Hello there,
This can be done by editing the template woocommerce/templates/cart/shipping-calculator.php.

woocommerce / templates / cart / shipping - calculator.php

The “Shipping Calculator” can be enabled via the WooCommerce settings in order to give the user a way to calculate their shipping fees before getting to the Checkout Page. Usually they fill out the country, state, city and postcode form fields and click on “Update Totals” in order to calculate the shipping.,Rodolfo – is there any .css that you can use to change the ‘calculate shipping’ to say ‘Please enter postcode to calculate shipping’? I have inspected the element and tried copying the code but an error on .css Any advice would be appreciated. Thanks Fastamir,Hmm. It doesn’t display the options, but it then doesn’t seem to calculate the shipping options when you submit it, just returning the calculate shipping string.,Shipping fees not calculated when the zip code is disabled on WooCommerce 5.1

 * @snippet       Remove Shipping Calculator Fields - WooCommerce Cart
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 5
 * @donate $9     https://businessbloomer.com/bloomer-armada/

// 1 Disable State
add_filter('woocommerce_shipping_calculator_enable_state', '__return_false');

// 2 Disable City
add_filter('woocommerce_shipping_calculator_enable_city', '__return_false');

// 3 Disable Postcode
add_filter('woocommerce_shipping_calculator_enable_postcode', '__return_false');
load more v

From the Dashboard menu, click on Appearance Menu > Theme Editor Menu. When the Theme Editor page is opened, look for the theme functions file to add the function to display the shipping calculator on the checkout page.,First, you need to add the following code on the woocommerce/cart/cart-shipping.php file:,After that, log into your WordPress site and access the Dashboard as the admin user.,How to Add Information to the WooCommerce Shop Page

  1. First, you need to add the following code on the woocommerce/cart/cart-shipping.php file:
if (is_checkout() & amp; & amp; !$show_shipping_calculator & amp; & amp;
   'yes' === get_option('woocommerce_enable_shipping_calc')) {
   $show_shipping_calculator = true;
load more v

Other "undefined-undefined" queries related to "Edit woocommerce shipping calculator"