Viewing 6 replies - 1 through 6 (of 6 total)
  • Thomas Shellberg

    (@shellbeezy)

    Automattic Happiness Engineer

    Are your shipping rules only set at the country level? If so, you could override and modify the shipping-calculator.php file and only leave in the Country select field; it should still work for calculating shipping at the country level.

    If you’re unsure how to override/modify templates, this should help:
    https://docs.woothemes.com/document/template-structure/

    Thread Starter seangnc

    (@seangnc)

    hi thomas, thanks for your response.
    my shipping plugin calculates the fee by CITY
    how can i add city field?
    thanks

    Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Shipping zones don’t work by city – they work by country, state, and zip codes.

    City is rather irrelevant when it comes to shipping things. I suppose you could use it for quick shipping calculations, but that will take some customization on your part.

    Thread Starter seangnc

    (@seangnc)

    @caleb, thanks for your reply. i need city NOT for shipping zones, but i only need it instead of state.

    what codes needed to replace this area?

    <section class="shipping-calculator-form" style="display:none;">
    
    		<p class="form-row form-row-wide" id="calc_shipping_country_field">
    			<select name="calc_shipping_country" id="calc_shipping_country" class="country_to_state" rel="calc_shipping_state">
    				<option value=""><?php _e( 'Select a country&hellip;', 'woocommerce' ); ?></option>
    				<?php
    					foreach( WC()->countries->get_shipping_countries() as $key => $value )
    						echo '<option value="' . esc_attr( $key ) . '"' . selected( WC()->customer->get_shipping_country(), esc_attr( $key ), false ) . '>' . esc_html( $value ) . '</option>';
    				?>
    			</select>
    		</p>
    
    		<p class="form-row form-row-wide" id="calc_shipping_state_field">
    			<?php
    				$current_cc = WC()->customer->get_shipping_country();
    				$current_r  = WC()->customer->get_shipping_state();
    				$states     = WC()->countries->get_states( $current_cc );
    
    				// Hidden Input
    				if ( is_array( $states ) && empty( $states ) ) {
    
    					?><input type="hidden" name="calc_shipping_state" id="calc_shipping_state" placeholder="<?php esc_attr_e( 'State / county', 'woocommerce' ); ?>" /><?php
    
    				// Dropdown Input
    				} elseif ( is_array( $states ) ) {
    
    					?><span>
    						<select name="calc_shipping_state" id="calc_shipping_state" placeholder="<?php esc_attr_e( 'State / county', 'woocommerce' ); ?>">
    							<option value=""><?php _e( 'Select a state&hellip;', 'woocommerce' ); ?></option>
    							<?php
    								foreach ( $states as $ckey => $cvalue )
    									echo '<option value="' . esc_attr( $ckey ) . '" ' . selected( $current_r, $ckey, false ) . '>' . __( esc_html( $cvalue ), 'woocommerce' ) .'</option>';
    							?>
    						</select>
    					</span><?php
    
    				// Standard Input
    				} else {
    
    					?><input type="text" class="input-text" value="<?php echo esc_attr( $current_r ); ?>" placeholder="<?php esc_attr_e( 'State / county', 'woocommerce' ); ?>" name="calc_shipping_state" id="calc_shipping_state" /><?php
    
    				}
    			?>
    		</p>
    
    		<?php if ( apply_filters( 'woocommerce_shipping_calculator_enable_city', false ) ) : ?>
    
    			<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" />
    			</p>
    
    		<?php endif; ?>
    
    		<?php if ( apply_filters( 'woocommerce_shipping_calculator_enable_postcode', true ) ) : ?>
    
    			<p class="form-row form-row-wide" id="calc_shipping_postcode_field">
    				<input type="text" class="input-text" value="<?php echo esc_attr( WC()->customer->get_shipping_postcode() ); ?>" placeholder="<?php esc_attr_e( 'Postcode / ZIP', 'woocommerce' ); ?>" name="calc_shipping_postcode" id="calc_shipping_postcode" />
    			</p>
    
    		<?php endif; ?>
    
    		<p><button type="submit" name="calc_shipping" value="1" class="button"><?php _e( 'Update Totals', 'woocommerce' ); ?></button></p>
    
    		<?php wp_nonce_field( 'woocommerce-cart' ); ?>
    	</section>
    Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    what codes needed to replace this area?

    I believe what you need is going to take a bit more customization than just some code changes in that template. Writing custom code like this is outside the scope of support that can be provided here, so if you need this done and can’t do it yourself – you may need to hire some help:

    https://jobs.wordpress.net/
    https://codeable.io/

    Hi,
    Could you help me? I would like to show only the zip code in my cart page for calculate the shipping. How can I modify my Shipping_calculator.php for this option? or how can I do this?

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Shipping Calculator show only City (remove State and Post Code)’ is closed to new replies.