| 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 3.6.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 |
<table id="shipping_method" class="woocommerce-shipping-methods sellkit-shipping-methods-one-page sellkit-checkout-widget-divider"> |
| 32 |
<?php foreach ( $available_methods as $method ) : ?> |
| 33 |
<tr class="sellkit-checkout-widget-divider"> |
| 34 |
<td class="sellkit-shipping-method-t1 sellkit-checkout-widget-divider"> |
| 35 |
<label class="wrp"> |
| 36 |
<?php |
| 37 |
if ( 1 < count( $available_methods ) ) { |
| 38 |
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. |
| 39 |
} else { |
| 40 |
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" />', $index, esc_attr( sanitize_title( $method->id ) ), esc_attr( $method->id ) ); // WPCS: XSS ok. |
| 41 |
} |
| 42 |
?> |
| 43 |
<span class="checkmark"></span> |
| 44 |
<label><?php echo $method->label; ?></label> |
| 45 |
</label> |
| 46 |
</td> |
| 47 |
<td class="sellkit-shipping-method-t3 sellkit-checkout-widget-divider"> |
| 48 |
<?php |
| 49 |
$decimal = get_option( 'woocommerce_price_num_decimals' ); |
| 50 |
$symbol = get_woocommerce_currency_symbol(); |
| 51 |
echo $symbol . number_format( $method->cost, $decimal ); |
| 52 |
?> |
| 53 |
</td> |
| 54 |
</tr> |
| 55 |
<?php endforeach; ?> |
| 56 |
</table> |
| 57 |
<?php if ( is_cart() ) : ?> |
| 58 |
<p class="woocommerce-shipping-destination"> |
| 59 |
<?php |
| 60 |
if ( $formatted_destination ) { |
| 61 |
// Translators: $s shipping destination. |
| 62 |
printf( esc_html__( 'Shipping to %s.', 'woocommerce' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' ); |
| 63 |
$calculator_text = esc_html__( 'Change address', 'woocommerce' ); |
| 64 |
} else { |
| 65 |
echo wp_kses_post( apply_filters( 'woocommerce_shipping_estimate_html', __( 'Shipping options will be updated during checkout.', 'woocommerce' ) ) ); |
| 66 |
} |
| 67 |
?> |
| 68 |
</p> |
| 69 |
<?php endif; ?> |
| 70 |
<?php |
| 71 |
elseif ( ! $has_calculated_shipping || ! $formatted_destination ) : |
| 72 |
if ( is_cart() && 'no' === get_option( 'woocommerce_enable_shipping_calc' ) ) { |
| 73 |
echo wp_kses_post( apply_filters( 'woocommerce_shipping_not_enabled_on_cart_html', __( 'Shipping costs are calculated during checkout.', 'woocommerce' ) ) ); |
| 74 |
} else { |
| 75 |
echo wp_kses_post( apply_filters( 'woocommerce_shipping_may_be_available_html', __( 'Enter your address to view shipping options.', 'woocommerce' ) ) ); |
| 76 |
} |
| 77 |
elseif ( ! is_cart() ) : |
| 78 |
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' ) ) ); |
| 79 |
else : |
| 80 |
// Translators: $s shipping destination. |
| 81 |
echo wp_kses_post( apply_filters( 'woocommerce_cart_no_shipping_available_html', sprintf( esc_html__( 'No shipping options were found for %s.', 'woocommerce' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' ) ) ); |
| 82 |
$calculator_text = esc_html__( 'Enter a different address', 'woocommerce' ); |
| 83 |
endif; |
| 84 |
?> |
| 85 |
|
| 86 |
<?php if ( $show_package_details ) : ?> |
| 87 |
<?php echo '<p class="woocommerce-shipping-contents"><small>' . esc_html( $package_details ) . '</small></p>'; ?> |
| 88 |
<?php endif; ?> |
| 89 |
|
| 90 |
<?php if ( $show_shipping_calculator ) : ?> |
| 91 |
<?php woocommerce_shipping_calculator( $calculator_text ); ?> |
| 92 |
<?php endif; ?> |
| 93 |
</td> |
| 94 |
</tr> |
| 95 |
|