cart-empty.php
3 years ago
cart-item-data.php
5 years ago
cart-shipping.php
3 years ago
cart-totals.php
5 years ago
cart.php
2 years ago
cross-sells.php
5 years ago
mini-cart.php
2 years ago
proceed-to-checkout-button.php
3 years ago
shipping-calculator.php
3 years ago
cart-shipping.php
98 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Shipping Methods Display |
| 4 | * |
| 5 | * In 2.1 we show methods per package. This allows for multiple methods per order if so desired. |
| 6 | * |
| 7 | * This template can be overridden by copying it to yourtheme/woocommerce/cart/cart-shipping.php. |
| 8 | * |
| 9 | * HOWEVER, on occasion WooCommerce will need to update template files and you |
| 10 | * (the theme developer) will need to copy the new files to your theme to |
| 11 | * maintain compatibility. We try to do this as little as possible, but it does |
| 12 | * happen. When this occurs the version of the template file will be bumped and |
| 13 | * the readme will list any important changes. |
| 14 | * |
| 15 | * @see https://docs.woocommerce.com/document/template-structure/ |
| 16 | * @package WooCommerce\Templates |
| 17 | * @version 7.3.0 |
| 18 | */ |
| 19 | |
| 20 | defined( 'ABSPATH' ) || exit; |
| 21 | |
| 22 | $formatted_destination = isset( $formatted_destination ) ? $formatted_destination : WC()->countries->get_formatted_address( $package['destination'], ', ' ); |
| 23 | $has_calculated_shipping = ! empty( $has_calculated_shipping ); |
| 24 | $show_shipping_calculator = ! empty( $show_shipping_calculator ); |
| 25 | $calculator_text = ''; |
| 26 | ?> |
| 27 | <tr class="woocommerce-shipping-totals shipping"> |
| 28 | <th><?php echo wp_kses_post( $package_name ); ?></th> |
| 29 | <td data-title="<?php echo esc_attr( $package_name ); ?>"> |
| 30 | <?php if ( $available_methods ) : ?> |
| 31 | <ul id="shipping_method" class="woocommerce-shipping-methods"> |
| 32 | <?php foreach ( $available_methods as $method ) : ?> |
| 33 | <li> |
| 34 | <?php |
| 35 | if ( 1 < count( $available_methods ) ) { |
| 36 | printf( '<input type="radio" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d_%2$s" value="%3$s" class="shipping_method" %4$s />', $index, esc_attr( sanitize_title( $method->id ) ), esc_attr( $method->id ), checked( $method->id, $chosen_method, false ) ); // WPCS: XSS ok. |
| 37 | } else { |
| 38 | printf( '<input type="hidden" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d_%2$s" value="%3$s" class="shipping_method" />', $index, esc_attr( sanitize_title( $method->id ) ), esc_attr( $method->id ) ); // WPCS: XSS ok. |
| 39 | } |
| 40 | printf( '<label for="shipping_method_%1$s_%2$s">%3$s</label>', $index, esc_attr( sanitize_title( $method->id ) ), wc_cart_totals_shipping_method_label( $method ) ); // WPCS: XSS ok. |
| 41 | do_action( 'woocommerce_after_shipping_rate', $method, $index ); |
| 42 | ?> |
| 43 | </li> |
| 44 | <?php endforeach; ?> |
| 45 | </ul> |
| 46 | <?php if ( is_cart() ) : ?> |
| 47 | <p class="woocommerce-shipping-destination"> |
| 48 | <?php |
| 49 | if ( $formatted_destination ) { |
| 50 | // Translators: $s shipping destination. |
| 51 | printf( esc_html__( 'Shipping to %s.', 'woocommerce' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' ); |
| 52 | $calculator_text = esc_html__( 'Change address', 'woocommerce' ); |
| 53 | } else { |
| 54 | echo wp_kses_post( apply_filters( 'woocommerce_shipping_estimate_html', __( 'Shipping options will be updated during checkout.', 'woocommerce' ) ) ); |
| 55 | } |
| 56 | ?> |
| 57 | </p> |
| 58 | <?php endif; ?> |
| 59 | <?php |
| 60 | elseif ( ! $has_calculated_shipping || ! $formatted_destination ) : |
| 61 | if ( is_cart() && 'no' === get_option( 'woocommerce_enable_shipping_calc' ) ) { |
| 62 | echo wp_kses_post( apply_filters( 'woocommerce_shipping_not_enabled_on_cart_html', __( 'Shipping costs are calculated during checkout.', 'woocommerce' ) ) ); |
| 63 | } else { |
| 64 | echo wp_kses_post( apply_filters( 'woocommerce_shipping_may_be_available_html', __( 'Enter your address to view shipping options.', 'woocommerce' ) ) ); |
| 65 | } |
| 66 | elseif ( ! is_cart() ) : |
| 67 | echo wp_kses_post( apply_filters( 'woocommerce_no_shipping_available_html', __( 'There are no shipping options available. Please ensure that your address has been entered correctly, or contact us if you need any help.', 'woocommerce' ) ) ); |
| 68 | else : |
| 69 | echo wp_kses_post( |
| 70 | /** |
| 71 | * Provides a means of overriding the default 'no shipping available' HTML string. |
| 72 | * |
| 73 | * @since 3.0.0 |
| 74 | * |
| 75 | * @param string $html HTML message. |
| 76 | * @param string $formatted_destination The formatted shipping destination. |
| 77 | */ |
| 78 | apply_filters( |
| 79 | 'woocommerce_cart_no_shipping_available_html', |
| 80 | // Translators: $s shipping destination. |
| 81 | sprintf( esc_html__( 'No shipping options were found for %s.', 'woocommerce' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' ), |
| 82 | $formatted_destination |
| 83 | ) |
| 84 | ); |
| 85 | $calculator_text = esc_html__( 'Enter a different address', 'woocommerce' ); |
| 86 | endif; |
| 87 | ?> |
| 88 | |
| 89 | <?php if ( $show_package_details ) : ?> |
| 90 | <?php echo '<p class="woocommerce-shipping-contents"><small>' . esc_html( $package_details ) . '</small></p>'; ?> |
| 91 | <?php endif; ?> |
| 92 | |
| 93 | <?php if ( $show_shipping_calculator ) : ?> |
| 94 | <?php woocommerce_shipping_calculator( $calculator_text ); ?> |
| 95 | <?php endif; ?> |
| 96 | </td> |
| 97 | </tr> |
| 98 |