html-admin-page-shipping-zones.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. exit;
  4. }
  5. ?>
  6. <h2 class="wc-shipping-zones-heading">
  7. <?php _e( 'Shipping zones', 'woocommerce' ); ?>
  8. <a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=shipping&zone_id=new' ); ?>" class="page-title-action"><?php esc_html_e( 'Add shipping zone', 'woocommerce' ); ?></a>
  9. </h2>
  10. <p><?php echo __( 'A shipping zone is a geographic region where a certain set of shipping methods are offered.', 'woocommerce' ) . ' ' . __( 'WooCommerce will match a customer to a single zone using their shipping address and present the shipping methods within that zone to them.', 'woocommerce' ); ?></p>
  11. <table class="wc-shipping-zones widefat">
  12. <thead>
  13. <tr>
  14. <th class="wc-shipping-zone-sort"><?php echo wc_help_tip( __( 'Drag and drop to re-order your custom zones. This is the order in which they will be matched against the customer address.', 'woocommerce' ) ); ?></th>
  15. <th class="wc-shipping-zone-name"><?php esc_html_e( 'Zone name', 'woocommerce' ); ?></th>
  16. <th class="wc-shipping-zone-region"><?php esc_html_e( 'Region(s)', 'woocommerce' ); ?></th>
  17. <th class="wc-shipping-zone-methods"><?php esc_html_e( 'Shipping method(s)', 'woocommerce' ); ?></th>
  18. </tr>
  19. </thead>
  20. <tbody class="wc-shipping-zone-rows"></tbody>
  21. <tbody>
  22. <tr data-id="0" class="wc-shipping-zone-worldwide">
  23. <td width="1%" class="wc-shipping-zone-worldwide"></td>
  24. <td class="wc-shipping-zone-name">
  25. <a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings&tab=shipping&zone_id=0' ) ); ?>"><?php esc_html_e( 'Locations not covered by your other zones', 'woocommerce' ); ?></a>
  26. <div class="row-actions">
  27. <a href="admin.php?page=wc-settings&amp;tab=shipping&amp;zone_id=0"><?php _e( 'Manage shipping methods', 'woocommerce' ); ?></a>
  28. </div>
  29. </td>
  30. <td class="wc-shipping-zone-region"><?php _e( 'This zone is <b>optionally</b> used for regions that are not included in any other shipping zone.', 'woocommerce' ); ?></td>
  31. <td class="wc-shipping-zone-methods">
  32. <ul>
  33. <?php
  34. $worldwide = new WC_Shipping_Zone( 0 );
  35. $methods = $worldwide->get_shipping_methods();
  36. uasort( $methods, 'wc_shipping_zone_method_order_uasort_comparison' );
  37. if ( ! empty( $methods ) ) {
  38. foreach ( $methods as $method ) {
  39. $class_name = 'yes' === $method->enabled ? 'method_enabled' : 'method_disabled';
  40. echo '<li class="wc-shipping-zone-method ' . esc_attr( $class_name ) . '">' . esc_html( $method->get_title() ) . '</li>';
  41. }
  42. } else {
  43. echo '<li class="wc-shipping-zone-method">' . __( 'No shipping methods offered to this zone.', 'woocommerce' ) . '</li>';
  44. }
  45. ?>
  46. </ul>
  47. </td>
  48. </tr>
  49. </tbody>
  50. </table>
  51. <script type="text/html" id="tmpl-wc-shipping-zone-row-blank">
  52. <?php if ( 0 === $method_count ) : ?>
  53. <tr>
  54. <td class="wc-shipping-zones-blank-state" colspan="4">
  55. <p class="main"><?php _e( 'A shipping zone is a geographic region where a certain set of shipping methods and rates apply.', 'woocommerce' ); ?></p>
  56. <p><?php _e( 'For example:', 'woocommerce' ); ?></p>
  57. <ul>
  58. <li><?php _e( 'Local zone = California ZIP 90210 = Local pickup', 'woocommerce' ); ?>
  59. <li><?php _e( 'US domestic zone = All US states = Flat rate shipping', 'woocommerce' ); ?>
  60. <li><?php _e( 'Europe zone = Any country in Europe = Flat rate shipping', 'woocommerce' ); ?>
  61. </ul>
  62. <p><?php _e( 'Add as many zones as you need &ndash; customers will only see the methods available for their address.', 'woocommerce' ); ?></p>
  63. <a class="button button-primary wc-shipping-zone-add" href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings&tab=shipping&zone_id=new' ) ); ?>"><?php _e( 'Add shipping zone', 'woocommerce' ); ?></a>
  64. </td>
  65. </tr>
  66. <?php endif; ?>
  67. </script>
  68. <script type="text/html" id="tmpl-wc-shipping-zone-row">
  69. <tr data-id="{{ data.zone_id }}">
  70. <td width="1%" class="wc-shipping-zone-sort"></td>
  71. <td class="wc-shipping-zone-name">
  72. <a href="admin.php?page=wc-settings&amp;tab=shipping&amp;zone_id={{ data.zone_id }}">{{ data.zone_name }}</a>
  73. <div class="row-actions">
  74. <a href="admin.php?page=wc-settings&amp;tab=shipping&amp;zone_id={{ data.zone_id }}"><?php _e( 'Edit', 'woocommerce' ); ?></a> | <a href="#" class="wc-shipping-zone-delete"><?php _e( 'Delete', 'woocommerce' ); ?></a>
  75. </div>
  76. </td>
  77. <td class="wc-shipping-zone-region">
  78. {{ data.formatted_zone_location }}
  79. </td>
  80. <td class="wc-shipping-zone-methods">
  81. <div><ul></ul></div>
  82. </td>
  83. </tr>
  84. </script>
  85. <script type="text/template" id="tmpl-wc-modal-add-shipping-method">
  86. <div class="wc-backbone-modal">
  87. <div class="wc-backbone-modal-content">
  88. <section class="wc-backbone-modal-main" role="main">
  89. <header class="wc-backbone-modal-header">
  90. <h1><?php _e( 'Add shipping method', 'woocommerce' ); ?></h1>
  91. <button class="modal-close modal-close-link dashicons dashicons-no-alt">
  92. <span class="screen-reader-text"><?php _e( 'Close modal panel', 'woocommerce' ); ?></span>
  93. </button>
  94. </header>
  95. <article>
  96. <form action="" method="post">
  97. <div class="wc-shipping-zone-method-selector">
  98. <p><?php esc_html_e( 'Choose the shipping method you wish to add. Only shipping methods which support zones are listed.', 'woocommerce' ); ?></p>
  99. <select name="add_method_id">
  100. <?php
  101. foreach ( WC()->shipping->load_shipping_methods() as $method ) {
  102. if ( ! $method->supports( 'shipping-zones' ) ) {
  103. continue;
  104. }
  105. echo '<option data-description="' . esc_attr( wp_kses_post( wpautop( $method->get_method_description() ) ) ) . '" value="' . esc_attr( $method->id ) . '">' . esc_attr( $method->get_method_title() ) . '</li>';
  106. }
  107. ?>
  108. </select>
  109. <input type="hidden" name="zone_id" value="{{{ data.zone_id }}}" />
  110. </div>
  111. </form>
  112. </article>
  113. <footer>
  114. <div class="inner">
  115. <button id="btn-ok" class="button button-primary button-large"><?php _e( 'Add shipping method', 'woocommerce' ); ?></button>
  116. </div>
  117. </footer>
  118. </section>
  119. </div>
  120. </div>
  121. <div class="wc-backbone-modal-backdrop modal-close"></div>
  122. </script>