Sin descripción

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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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', $zone ); ?>
  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_attr_e( 'Select regions within this zone', 'woocommerce' ); ?>" class="wc-shipping-zone-region-select chosen_select">
  39. <?php
  40. foreach ( $shipping_continents as $continent_code => $continent ) {
  41. echo '<option value="continent:' . esc_attr( $continent_code ) . '"' . wc_selected( "continent:$continent_code", $locations ) . '>' . 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 ) . '>' . esc_html( '&nbsp;&nbsp; ' . $allowed_countries[ $country_code ] ) . '</option>';
  45. $states = WC()->countries->get_states( $country_code );
  46. if ( $states ) {
  47. foreach ( $states as $state_code => $state_name ) {
  48. echo '<option value="state:' . esc_attr( $country_code . ':' . $state_code ) . '"' . wc_selected( "state:$country_code:$state_code", $locations ) . '>' . esc_html( '&nbsp;&nbsp;&nbsp;&nbsp; ' . $state_name . ', ' . $allowed_countries[ $country_code ] ) . '</option>';
  49. }
  50. }
  51. }
  52. }
  53. ?>
  54. </select>
  55. <?php if ( empty( $postcodes ) ) : ?>
  56. <a class="wc-shipping-zone-postcodes-toggle" href="#"><?php esc_html_e( 'Limit to specific ZIP/postcodes', 'woocommerce' ); ?></a>
  57. <?php endif; ?>
  58. <div class="wc-shipping-zone-postcodes">
  59. <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>
  60. <?php /* translators: WooCommerce link to setting up shipping zones */ ?>
  61. <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. ?>
  62. </div>
  63. </td>
  64. <?php endif; ?>
  65. </tr>
  66. <tr valign="top" class="">
  67. <th scope="row" class="titledesc">
  68. <label>
  69. <?php esc_html_e( 'Shipping methods', 'woocommerce' ); ?>
  70. <?php echo wc_help_tip( __( 'The following shipping methods apply to customers with shipping addresses within this zone.', 'woocommerce' ) ); // @codingStandardsIgnoreLine ?>
  71. </label>
  72. </th>
  73. <td class="">
  74. <table class="wc-shipping-zone-methods widefat">
  75. <thead>
  76. <tr>
  77. <th class="wc-shipping-zone-method-sort"></th>
  78. <th class="wc-shipping-zone-method-title"><?php esc_html_e( 'Title', 'woocommerce' ); ?></th>
  79. <th class="wc-shipping-zone-method-enabled"><?php esc_html_e( 'Enabled', 'woocommerce' ); ?></th>
  80. <th class="wc-shipping-zone-method-description"><?php esc_html_e( 'Description', 'woocommerce' ); ?></th>
  81. </tr>
  82. </thead>
  83. <tfoot>
  84. <tr>
  85. <td colspan="4">
  86. <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>
  87. </td>
  88. </tr>
  89. </tfoot>
  90. <tbody class="wc-shipping-zone-method-rows"></tbody>
  91. </table>
  92. </td>
  93. </tr>
  94. </tbody>
  95. </table>
  96. <?php do_action( 'woocommerce_shipping_zone_after_methods_table', $zone ); ?>
  97. <p class="submit">
  98. <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>
  99. </p>
  100. <script type="text/html" id="tmpl-wc-shipping-zone-method-row-blank">
  101. <tr>
  102. <td class="wc-shipping-zone-method-blank-state" colspan="4">
  103. <p><?php esc_html_e( 'You can add multiple shipping methods within this zone. Only customers within the zone will see them.', 'woocommerce' ); ?></p>
  104. </td>
  105. </tr>
  106. </script>
  107. <script type="text/html" id="tmpl-wc-shipping-zone-method-row">
  108. <tr data-id="{{ data.instance_id }}" data-enabled="{{ data.enabled }}">
  109. <td width="1%" class="wc-shipping-zone-method-sort"></td>
  110. <td class="wc-shipping-zone-method-title">
  111. <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>
  112. <div class="row-actions">
  113. <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>
  114. </div>
  115. </td>
  116. <td width="1%" class="wc-shipping-zone-method-enabled"><a href="#">{{{ data.enabled_icon }}}</a></td>
  117. <td class="wc-shipping-zone-method-description">
  118. <strong class="wc-shipping-zone-method-type">{{ data.method_title }}</strong>
  119. {{{ data.method_description }}}
  120. </td>
  121. </tr>
  122. </script>
  123. <script type="text/template" id="tmpl-wc-modal-shipping-method-settings">
  124. <div class="wc-backbone-modal wc-backbone-modal-shipping-method-settings">
  125. <div class="wc-backbone-modal-content">
  126. <section class="wc-backbone-modal-main" role="main">
  127. <header class="wc-backbone-modal-header">
  128. <h1>
  129. <?php
  130. printf(
  131. /* translators: %s: shipping method title */
  132. esc_html__( '%s Settings', 'woocommerce' ),
  133. '{{{ data.method.method_title }}}'
  134. );
  135. ?>
  136. </h1>
  137. <button class="modal-close modal-close-link dashicons dashicons-no-alt">
  138. <span class="screen-reader-text"><?php esc_html_e( 'Close modal panel', 'woocommerce' ); ?></span>
  139. </button>
  140. </header>
  141. <article class="wc-modal-shipping-method-settings">
  142. <form action="" method="post">
  143. {{{ data.method.settings_html }}}
  144. <input type="hidden" name="instance_id" value="{{{ data.instance_id }}}" />
  145. </form>
  146. </article>
  147. <footer>
  148. <div class="inner">
  149. <button id="btn-ok" class="button button-primary button-large"><?php esc_html_e( 'Save changes', 'woocommerce' ); ?></button>
  150. </div>
  151. </footer>
  152. </section>
  153. </div>
  154. </div>
  155. <div class="wc-backbone-modal-backdrop modal-close"></div>
  156. </script>
  157. <script type="text/template" id="tmpl-wc-modal-add-shipping-method">
  158. <div class="wc-backbone-modal">
  159. <div class="wc-backbone-modal-content">
  160. <section class="wc-backbone-modal-main" role="main">
  161. <header class="wc-backbone-modal-header">
  162. <h1><?php esc_html_e( 'Add shipping method', 'woocommerce' ); ?></h1>
  163. <button class="modal-close modal-close-link dashicons dashicons-no-alt">
  164. <span class="screen-reader-text"><?php esc_html_e( 'Close modal panel', 'woocommerce' ); ?></span>
  165. </button>
  166. </header>
  167. <article>
  168. <form action="" method="post">
  169. <div class="wc-shipping-zone-method-selector">
  170. <p><?php esc_html_e( 'Choose the shipping method you wish to add. Only shipping methods which support zones are listed.', 'woocommerce' ); ?></p>
  171. <select name="add_method_id">
  172. <?php
  173. foreach ( WC()->shipping()->load_shipping_methods() as $method ) {
  174. if ( ! $method->supports( 'shipping-zones' ) ) {
  175. continue;
  176. }
  177. echo '<option data-description="' . esc_attr( wp_kses_post( wpautop( $method->get_method_description() ) ) ) . '" value="' . esc_attr( $method->id ) . '">' . esc_html( $method->get_method_title() ) . '</li>';
  178. }
  179. ?>
  180. </select>
  181. </div>
  182. </form>
  183. </article>
  184. <footer>
  185. <div class="inner">
  186. <button id="btn-ok" class="button button-primary button-large"><?php esc_html_e( 'Add shipping method', 'woocommerce' ); ?></button>
  187. </div>
  188. </footer>
  189. </section>
  190. </div>
  191. </div>
  192. <div class="wc-backbone-modal-backdrop modal-close"></div>
  193. </script>