html-admin-page-shipping-zone-methods.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <?php
  2. /**
  3. * Shipping zone admin
  4. *
  5. * @package WooCommerce/Admin/Shipping
  6. */
  7. if ( ! defined( 'ABSPATH' ) ) {
  8. exit;
  9. }
  10. ?>
  11. <h2>
  12. <a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings&tab=shipping' ) ); ?>"><?php esc_html_e( 'Shipping zones', 'woocommerce' ); ?></a> &gt;
  13. <span class="wc-shipping-zone-name"><?php echo esc_html( $zone->get_zone_name() ? $zone->get_zone_name() : __( 'Zone', 'woocommerce' ) ); ?></span>
  14. </h2>
  15. <?php do_action( 'woocommerce_shipping_zone_before_methods_table' ); ?>
  16. <table class="form-table wc-shipping-zone-settings">
  17. <tbody>
  18. <?php if ( 0 !== $zone->get_id() ) : ?>
  19. <tr valign="top" class="">
  20. <th scope="row" class="titledesc">
  21. <label for="zone_name">
  22. <?php esc_html_e( 'Zone name', 'woocommerce' ); ?>
  23. <?php echo wc_help_tip( __( 'This is the name of the zone for your reference.', 'woocommerce' ) ); // @codingStandardsIgnoreLine ?>
  24. </label>
  25. </th>
  26. <td class="forminp">
  27. <input type="text" data-attribute="zone_name" name="zone_name" id="zone_name" value="<?php echo esc_attr( $zone->get_zone_name( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'Zone name', 'woocommerce' ); ?>">
  28. </td>
  29. </tr>
  30. <tr valign="top" class="">
  31. <th scope="row" class="titledesc">
  32. <label for="zone_locations">
  33. <?php esc_html_e( 'Zone regions', 'woocommerce' ); ?>
  34. <?php echo wc_help_tip( __( 'These are regions inside this zone. Customers will be matched against these regions.', 'woocommerce' ) ); // @codingStandardsIgnoreLine ?>
  35. </label>
  36. </th>
  37. <td class="forminp">
  38. <select multiple="multiple" data-attribute="zone_locations" id="zone_locations" name="zone_locations" data-placeholder="<?php esc_html_e( 'Select regions within this zone', 'woocommerce' ); ?>" class="wc-shipping-zone-region-select chosen_select">
  39. <?php
  40. foreach ( $continents as $continent_code => $continent ) {
  41. echo '<option value="continent:' . esc_attr( $continent_code ) . '"' . wc_selected( "continent:$continent_code", $locations ) . ' alt="">' . esc_html( $continent['name'] ) . '</option>';
  42. $countries = array_intersect( array_keys( $allowed_countries ), $continent['countries'] );
  43. foreach ( $countries as $country_code ) {
  44. echo '<option value="country:' . esc_attr( $country_code ) . '"' . wc_selected( "country:$country_code", $locations ) . ' alt="' . esc_attr( $continent['name'] ) . '">' . esc_html( '&nbsp;&nbsp; ' . $allowed_countries[ $country_code ] ) . '</option>';
  45. if ( $states = WC()->countries->get_states( $country_code ) ) {
  46. foreach ( $states as $state_code => $state_name ) {
  47. echo '<option value="state:' . esc_attr( $country_code . ':' . $state_code ) . '"' . wc_selected( "state:$country_code:$state_code", $locations ) . ' alt="' . esc_attr( $continent['name'] . ' ' . $allowed_countries[ $country_code ] ) . '">' . esc_html( '&nbsp;&nbsp;&nbsp;&nbsp; ' . $state_name ) . '</option>';
  48. }
  49. }
  50. }
  51. }
  52. ?>
  53. </select>
  54. <?php if ( empty( $postcodes ) ) : ?>
  55. <a class="wc-shipping-zone-postcodes-toggle" href="#"><?php esc_html_e( 'Limit to specific ZIP/postcodes', 'woocommerce' ); ?></a>
  56. <?php endif; ?>
  57. <div class="wc-shipping-zone-postcodes">
  58. <textarea name="zone_postcodes" data-attribute="zone_postcodes" id="zone_postcodes" placeholder="<?php esc_attr_e( 'List 1 postcode per line', 'woocommerce' ); ?>" class="input-text large-text" cols="25" rows="5"><?php echo esc_textarea( implode( "\n", $postcodes ) ); ?></textarea>
  59. <?php /* translators: WooCommerce link to setting up shipping zones */ ?>
  60. <span class="description"><?php printf( __( 'Postcodes containing wildcards (e.g. CB23*) or fully numeric ranges (e.g. <code>90210...99000</code>) are also supported. Please see the shipping zones <a href="%s" target="_blank">documentation</a>) for more information.', 'woocommerce' ), 'https://docs.woocommerce.com/document/setting-up-shipping-zones/#section-3' ); ?></span><?php // @codingStandardsIgnoreLine. ?>
  61. </div>
  62. </td>
  63. <?php endif; ?>
  64. </tr>
  65. <tr valign="top" class="">
  66. <th scope="row" class="titledesc">
  67. <label>
  68. <?php esc_html_e( 'Shipping methods', 'woocommerce' ); ?>
  69. <?php echo wc_help_tip( __( 'The following shipping methods apply to customers with shipping addresses within this zone.', 'woocommerce' ) ); // @codingStandardsIgnoreLine ?>
  70. </label>
  71. </th>
  72. <td class="">
  73. <table class="wc-shipping-zone-methods widefat">
  74. <thead>
  75. <tr>
  76. <th class="wc-shipping-zone-method-sort"></th>
  77. <th class="wc-shipping-zone-method-title"><?php esc_html_e( 'Title', 'woocommerce' ); ?></th>
  78. <th class="wc-shipping-zone-method-enabled"><?php esc_html_e( 'Enabled', 'woocommerce' ); ?></th>
  79. <th class="wc-shipping-zone-method-description"><?php esc_html_e( 'Description', 'woocommerce' ); ?></th>
  80. </tr>
  81. </thead>
  82. <tfoot>
  83. <tr>
  84. <td colspan="4">
  85. <button type="submit" class="button wc-shipping-zone-add-method" value="<?php esc_attr_e( 'Add shipping method', 'woocommerce' ); ?>"><?php esc_html_e( 'Add shipping method', 'woocommerce' ); ?></button>
  86. </td>
  87. </tr>
  88. </tfoot>
  89. <tbody class="wc-shipping-zone-method-rows"></tbody>
  90. </table>
  91. </td>
  92. </tr>
  93. </tbody>
  94. </table>
  95. <p class="submit">
  96. <button type="submit" name="submit" id="submit" class="button button-primary button-large wc-shipping-zone-method-save" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ); ?>" disabled><?php esc_html_e( 'Save changes', 'woocommerce' ); ?></button>
  97. </p>
  98. <script type="text/html" id="tmpl-wc-shipping-zone-method-row-blank">
  99. <tr>
  100. <td class="wc-shipping-zone-method-blank-state" colspan="4">
  101. <p><?php esc_html_e( 'You can add multiple shipping methods within this zone. Only customers within the zone will see them.', 'woocommerce' ); ?></p>
  102. </td>
  103. </tr>
  104. </script>
  105. <script type="text/html" id="tmpl-wc-shipping-zone-method-row">
  106. <tr data-id="{{ data.instance_id }}" data-enabled="{{ data.enabled }}">
  107. <td width="1%" class="wc-shipping-zone-method-sort"></td>
  108. <td class="wc-shipping-zone-method-title">
  109. <a class="wc-shipping-zone-method-settings" href="admin.php?page=wc-settings&amp;tab=shipping&amp;instance_id={{ data.instance_id }}">{{{ data.title }}}</a>
  110. <div class="row-actions">
  111. <a class="wc-shipping-zone-method-settings" href="admin.php?page=wc-settings&amp;tab=shipping&amp;instance_id={{ data.instance_id }}"><?php esc_html_e( 'Edit', 'woocommerce' ); ?></a> | <a href="#" class="wc-shipping-zone-method-delete"><?php esc_html_e( 'Delete', 'woocommerce' ); ?></a>
  112. </div>
  113. </td>
  114. <td width="1%" class="wc-shipping-zone-method-enabled"><a href="#">{{{ data.enabled_icon }}}</a></td>
  115. <td class="wc-shipping-zone-method-description">
  116. <strong class="wc-shipping-zone-method-type">{{ data.method_title }}</strong>
  117. {{{ data.method_description }}}
  118. </td>
  119. </tr>
  120. </script>
  121. <script type="text/template" id="tmpl-wc-modal-shipping-method-settings">
  122. <div class="wc-backbone-modal wc-backbone-modal-shipping-method-settings">
  123. <div class="wc-backbone-modal-content">
  124. <section class="wc-backbone-modal-main" role="main">
  125. <header class="wc-backbone-modal-header">
  126. <h1>
  127. <?php
  128. /* translators: %s: shipping method title */
  129. printf(
  130. esc_html__( '%s Settings', 'woocommerce' ),
  131. '{{{ data.method.method_title }}}'
  132. );
  133. ?>
  134. </h1>
  135. <button class="modal-close modal-close-link dashicons dashicons-no-alt">
  136. <span class="screen-reader-text"><?php esc_html_e( 'Close modal panel', 'woocommerce' ); ?></span>
  137. </button>
  138. </header>
  139. <article class="wc-modal-shipping-method-settings">
  140. <form action="" method="post">
  141. {{{ data.method.settings_html }}}
  142. <input type="hidden" name="instance_id" value="{{{ data.instance_id }}}" />
  143. </form>
  144. </article>
  145. <footer>
  146. <div class="inner">
  147. <button id="btn-ok" class="button button-primary button-large"><?php esc_html_e( 'Save changes', 'woocommerce' ); ?></button>
  148. </div>
  149. </footer>
  150. </section>
  151. </div>
  152. </div>
  153. <div class="wc-backbone-modal-backdrop modal-close"></div>
  154. </script>
  155. <script type="text/template" id="tmpl-wc-modal-add-shipping-method">
  156. <div class="wc-backbone-modal">
  157. <div class="wc-backbone-modal-content">
  158. <section class="wc-backbone-modal-main" role="main">
  159. <header class="wc-backbone-modal-header">
  160. <h1><?php esc_html_e( 'Add shipping method', 'woocommerce' ); ?></h1>
  161. <button class="modal-close modal-close-link dashicons dashicons-no-alt">
  162. <span class="screen-reader-text"><?php esc_html_e( 'Close modal panel', 'woocommerce' ); ?></span>
  163. </button>
  164. </header>
  165. <article>
  166. <form action="" method="post">
  167. <div class="wc-shipping-zone-method-selector">
  168. <p><?php esc_html_e( 'Choose the shipping method you wish to add. Only shipping methods which support zones are listed.', 'woocommerce' ); ?></p>
  169. <select name="add_method_id">
  170. <?php
  171. foreach ( WC()->shipping->load_shipping_methods() as $method ) {
  172. if ( ! $method->supports( 'shipping-zones' ) ) {
  173. continue;
  174. }
  175. 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>';
  176. }
  177. ?>
  178. </select>
  179. </div>
  180. </form>
  181. </article>
  182. <footer>
  183. <div class="inner">
  184. <button id="btn-ok" class="button button-primary button-large"><?php esc_html_e( 'Add shipping method', 'woocommerce' ); ?></button>
  185. </div>
  186. </footer>
  187. </section>
  188. </div>
  189. </div>
  190. <div class="wc-backbone-modal-backdrop modal-close"></div>
  191. </script>