cart-empty.php
7 years ago
cart-item-data.php
7 years ago
cart-shipping.php
6 years ago
cart-totals.php
6 years ago
cart.php
6 years ago
cross-sells.php
6 years ago
mini-cart.php
6 years ago
proceed-to-checkout-button.php
7 years ago
shipping-calculator.php
7 years ago
shipping-calculator.php
92 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Shipping Calculator |
| 4 | * |
| 5 | * This template can be overridden by copying it to yourtheme/woocommerce/cart/shipping-calculator.php. |
| 6 | * |
| 7 | * HOWEVER, on occasion WooCommerce will need to update template files and you |
| 8 | * (the theme developer) will need to copy the new files to your theme to |
| 9 | * maintain compatibility. We try to do this as little as possible, but it does |
| 10 | * happen. When this occurs the version of the template file will be bumped and |
| 11 | * the readme will list any important changes. |
| 12 | * |
| 13 | * @see https://docs.woocommerce.com/document/template-structure/ |
| 14 | * @package WooCommerce/Templates |
| 15 | * @version 3.5.0 |
| 16 | */ |
| 17 | |
| 18 | defined( 'ABSPATH' ) || exit; |
| 19 | |
| 20 | do_action( 'woocommerce_before_shipping_calculator' ); ?> |
| 21 | |
| 22 | <form class="woocommerce-shipping-calculator" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post"> |
| 23 | |
| 24 | <?php printf( '<a href="#" class="shipping-calculator-button">%s</a>', esc_html( ! empty( $button_text ) ? $button_text : __( 'Calculate shipping', 'woocommerce' ) ) ); ?> |
| 25 | |
| 26 | <section class="shipping-calculator-form" style="display:none;"> |
| 27 | |
| 28 | <?php if ( apply_filters( 'woocommerce_shipping_calculator_enable_country', true ) ) : ?> |
| 29 | <p class="form-row form-row-wide" id="calc_shipping_country_field"> |
| 30 | <select name="calc_shipping_country" id="calc_shipping_country" class="country_to_state country_select" rel="calc_shipping_state"> |
| 31 | <option value=""><?php esc_html_e( 'Select a country…', 'woocommerce' ); ?></option> |
| 32 | <?php |
| 33 | foreach ( WC()->countries->get_shipping_countries() as $key => $value ) { |
| 34 | echo '<option value="' . esc_attr( $key ) . '"' . selected( WC()->customer->get_shipping_country(), esc_attr( $key ), false ) . '>' . esc_html( $value ) . '</option>'; |
| 35 | } |
| 36 | ?> |
| 37 | </select> |
| 38 | </p> |
| 39 | <?php endif; ?> |
| 40 | |
| 41 | <?php if ( apply_filters( 'woocommerce_shipping_calculator_enable_state', true ) ) : ?> |
| 42 | <p class="form-row form-row-wide" id="calc_shipping_state_field"> |
| 43 | <?php |
| 44 | $current_cc = WC()->customer->get_shipping_country(); |
| 45 | $current_r = WC()->customer->get_shipping_state(); |
| 46 | $states = WC()->countries->get_states( $current_cc ); |
| 47 | |
| 48 | if ( is_array( $states ) && empty( $states ) ) { |
| 49 | ?> |
| 50 | <input type="hidden" name="calc_shipping_state" id="calc_shipping_state" placeholder="<?php esc_attr_e( 'State / County', 'woocommerce' ); ?>" /> |
| 51 | <?php |
| 52 | } elseif ( is_array( $states ) ) { |
| 53 | ?> |
| 54 | <span> |
| 55 | <select name="calc_shipping_state" class="state_select" id="calc_shipping_state" data-placeholder="<?php esc_attr_e( 'State / County', 'woocommerce' ); ?>"> |
| 56 | <option value=""><?php esc_html_e( 'Select an option…', 'woocommerce' ); ?></option> |
| 57 | <?php |
| 58 | foreach ( $states as $ckey => $cvalue ) { |
| 59 | echo '<option value="' . esc_attr( $ckey ) . '" ' . selected( $current_r, $ckey, false ) . '>' . esc_html( $cvalue ) . '</option>'; |
| 60 | } |
| 61 | ?> |
| 62 | </select> |
| 63 | </span> |
| 64 | <?php |
| 65 | } else { |
| 66 | ?> |
| 67 | <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" /> |
| 68 | <?php |
| 69 | } |
| 70 | ?> |
| 71 | </p> |
| 72 | <?php endif; ?> |
| 73 | |
| 74 | <?php if ( apply_filters( 'woocommerce_shipping_calculator_enable_city', true ) ) : ?> |
| 75 | <p class="form-row form-row-wide" id="calc_shipping_city_field"> |
| 76 | <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" /> |
| 77 | </p> |
| 78 | <?php endif; ?> |
| 79 | |
| 80 | <?php if ( apply_filters( 'woocommerce_shipping_calculator_enable_postcode', true ) ) : ?> |
| 81 | <p class="form-row form-row-wide" id="calc_shipping_postcode_field"> |
| 82 | <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" /> |
| 83 | </p> |
| 84 | <?php endif; ?> |
| 85 | |
| 86 | <p><button type="submit" name="calc_shipping" value="1" class="button"><?php esc_html_e( 'Update', 'woocommerce' ); ?></button></p> |
| 87 | <?php wp_nonce_field( 'woocommerce-shipping-calculator', 'woocommerce-shipping-calculator-nonce' ); ?> |
| 88 | </section> |
| 89 | </form> |
| 90 | |
| 91 | <?php do_action( 'woocommerce_after_shipping_calculator' ); ?> |
| 92 |