cart-shipping.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. * @author WooThemes
  17. * @package WooCommerce/Templates
  18. * @version 3.2.0
  19. */
  20. if ( ! defined( 'ABSPATH' ) ) {
  21. exit;
  22. }
  23. ?>
  24. <tr class="shipping">
  25. <th><?php echo wp_kses_post( $package_name ); ?></th>
  26. <td data-title="<?php echo esc_attr( $package_name ); ?>">
  27. <?php if ( 1 < count( $available_methods ) ) : ?>
  28. <ul id="shipping_method">
  29. <?php foreach ( $available_methods as $method ) : ?>
  30. <li>
  31. <?php
  32. 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 />
  33. <label for="shipping_method_%1$d_%2$s">%5$s</label>',
  34. $index, sanitize_title( $method->id ), esc_attr( $method->id ), checked( $method->id, $chosen_method, false ), wc_cart_totals_shipping_method_label( $method ) );
  35. do_action( 'woocommerce_after_shipping_rate', $method, $index );
  36. ?>
  37. </li>
  38. <?php endforeach; ?>
  39. </ul>
  40. <?php elseif ( 1 === count( $available_methods ) ) : ?>
  41. <?php
  42. $method = current( $available_methods );
  43. printf( '%3$s <input type="hidden" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d" value="%2$s" class="shipping_method" />', $index, esc_attr( $method->id ), wc_cart_totals_shipping_method_label( $method ) );
  44. do_action( 'woocommerce_after_shipping_rate', $method, $index );
  45. ?>
  46. <?php elseif ( WC()->customer->has_calculated_shipping() ) : ?>
  47. <?php
  48. if ( is_cart() ) {
  49. echo apply_filters( 'woocommerce_cart_no_shipping_available_html', wpautop( __( 'There are no shipping methods available. Please ensure that your address has been entered correctly, or contact us if you need any help.', 'woocommerce' ) ) );
  50. } else {
  51. echo apply_filters( 'woocommerce_no_shipping_available_html', wpautop( __( 'There are no shipping methods available. Please ensure that your address has been entered correctly, or contact us if you need any help.', 'woocommerce' ) ) );
  52. }
  53. ?>
  54. <?php elseif ( ! is_cart() ) : ?>
  55. <?php echo wpautop( __( 'Enter your full address to see shipping costs.', 'woocommerce' ) ); ?>
  56. <?php endif; ?>
  57. <?php if ( $show_package_details ) : ?>
  58. <?php echo '<p class="woocommerce-shipping-contents"><small>' . esc_html( $package_details ) . '</small></p>'; ?>
  59. <?php endif; ?>
  60. <?php if ( ! empty( $show_shipping_calculator ) ) : ?>
  61. <?php woocommerce_shipping_calculator(); ?>
  62. <?php endif; ?>
  63. </td>
  64. </tr>