class-wc-settings-rest-api.php
5 years ago
html-admin-page-shipping-classes.php
1 month ago
html-admin-page-shipping-providers.php
1 month ago
html-admin-page-shipping-zone-methods.php
1 month ago
html-admin-page-shipping-zones-instance.php
8 years ago
html-admin-page-shipping-zones.php
1 month ago
html-keys-edit.php
1 month ago
html-settings-tax.php
1 year ago
html-webhooks-edit.php
1 month ago
settings-tax.php
2 months ago
html-admin-page-shipping-zone-methods.php
281 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Shipping zone admin |
| 4 | * |
| 5 | * @package WooCommerce\Admin\Shipping |
| 6 | */ |
| 7 | |
| 8 | use Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils; |
| 9 | use Automattic\WooCommerce\Blocks\Shipping\ShippingController; |
| 10 | use Automattic\WooCommerce\StoreApi\Utilities\LocalPickupUtils; |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; |
| 14 | } |
| 15 | ?> |
| 16 | |
| 17 | |
| 18 | <?php wc_back_header( $zone->get_zone_name() ? $zone->get_zone_name() : __( 'Add zone', 'woocommerce' ), __( 'Return to shipping', 'woocommerce' ), admin_url( 'admin.php?page=wc-settings&tab=shipping' ) ); ?> |
| 19 | |
| 20 | <?php |
| 21 | // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment |
| 22 | do_action( 'woocommerce_shipping_zone_before_methods_table', $zone ); |
| 23 | ?> |
| 24 | |
| 25 | <table class="form-table wc-shipping-zone-settings"> |
| 26 | <tbody> |
| 27 | <?php if ( 0 !== $zone->get_id() ) : ?> |
| 28 | <tr valign="top" class=""> |
| 29 | <th scope="row" class="titledesc"> |
| 30 | <label for="zone_name"> |
| 31 | <?php esc_html_e( 'Zone name', 'woocommerce' ); ?> |
| 32 | </label> |
| 33 | <p class="wc-shipping-zone-help-text"> |
| 34 | <?php esc_html_e( 'Give your zone a name! E.g. Local, or Worldwide.', 'woocommerce' ); ?> |
| 35 | </p> |
| 36 | </th> |
| 37 | <td class="forminp"> |
| 38 | <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' ); ?>"> |
| 39 | </td> |
| 40 | </tr> |
| 41 | <tr valign="top" class=""> |
| 42 | <th scope="row" class="titledesc"> |
| 43 | <label for="zone_locations"> |
| 44 | <?php esc_html_e( 'Zone regions', 'woocommerce' ); ?> |
| 45 | </label> |
| 46 | <p class="wc-shipping-zone-help-text"> |
| 47 | <?php esc_html_e( 'List the regions you\'d like to include in your shipping zone. Customers will be matched against these regions.', 'woocommerce' ); ?> |
| 48 | </p> |
| 49 | </th> |
| 50 | <td> |
| 51 | <div> |
| 52 | <div id="wc-shipping-zone-region-picker-root"/> |
| 53 | </div> |
| 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://woocommerce.com/document/setting-up-shipping-zones/#section-3' ); ?></span><?php // @codingStandardsIgnoreLine. ?> |
| 61 | </div> |
| 62 | </td> |
| 63 | </tr> |
| 64 | <?php endif; ?> |
| 65 | <tr valign="top" class=""> |
| 66 | <th scope="row" class="titledesc"> |
| 67 | <label> |
| 68 | <?php esc_html_e( 'Shipping methods', 'woocommerce' ); ?> |
| 69 | </label> |
| 70 | <p class="wc-shipping-zone-help-text"> |
| 71 | <?php esc_html_e( 'Add the shipping methods you\'d like to make available to customers in this zone.', 'woocommerce' ); ?> |
| 72 | </p> |
| 73 | </th> |
| 74 | <td class=""> |
| 75 | <table class="wc-shipping-zone-methods widefat"> |
| 76 | <thead> |
| 77 | <tr> |
| 78 | <th class="wc-shipping-zone-method-sort"></th> |
| 79 | <th class="wc-shipping-zone-method-title"><?php esc_html_e( 'Title', 'woocommerce' ); ?></th> |
| 80 | <th class="wc-shipping-zone-method-enabled"><?php esc_html_e( 'Enabled', 'woocommerce' ); ?></th> |
| 81 | <th class="wc-shipping-zone-method-description"><?php esc_html_e( 'Description', 'woocommerce' ); ?></th> |
| 82 | <th></th> |
| 83 | </tr> |
| 84 | </thead> |
| 85 | <tbody class="wc-shipping-zone-method-rows wc-shipping-tables-tbody"></tbody> |
| 86 | </table> |
| 87 | </td> |
| 88 | </tr> |
| 89 | <tr> |
| 90 | <th scope="row"></th> |
| 91 | <td> |
| 92 | <button type="submit" class="wc-shipping-zone-add-method components-button is-primary" value="<?php esc_attr_e( 'Add shipping method', 'woocommerce' ); ?>"><?php esc_html_e( 'Add shipping method', 'woocommerce' ); ?></button> |
| 93 | </td> |
| 94 | </tr> |
| 95 | </tbody> |
| 96 | </table> |
| 97 | |
| 98 | <?php |
| 99 | // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment |
| 100 | do_action( 'woocommerce_shipping_zone_after_methods_table', $zone ); |
| 101 | ?> |
| 102 | |
| 103 | <p class="submit"> |
| 104 | <button type="submit" name="submit" id="submit" class="button-primary button-large wc-shipping-zone-method-save components-button is-primary" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ); ?>" disabled><?php esc_html_e( 'Save changes', 'woocommerce' ); ?></button> |
| 105 | </p> |
| 106 | |
| 107 | <script type="text/html" id="tmpl-wc-shipping-zone-method-row-blank"> |
| 108 | <tr> |
| 109 | <td class="wc-shipping-zone-method-blank-state" colspan="5"> |
| 110 | <p><?php esc_html_e( 'You can add multiple shipping methods within this zone. Only customers within the zone will see them.', 'woocommerce' ); ?></p> |
| 111 | </td> |
| 112 | </tr> |
| 113 | </script> |
| 114 | |
| 115 | <script type="text/html" id="tmpl-wc-shipping-zone-method-row"> |
| 116 | <tr data-id="{{ data.instance_id }}" data-enabled="{{ data.enabled }}"> |
| 117 | <td width="1%" class="wc-shipping-zone-method-sort"></td> |
| 118 | <td class="wc-shipping-zone-method-title"> |
| 119 | {{{ data.title }}} |
| 120 | </td> |
| 121 | <td width="1%" class="wc-shipping-zone-method-enabled"><a href="#">{{{ data.enabled_icon }}}</a></td> |
| 122 | <td class="wc-shipping-zone-method-description"> |
| 123 | {{{ data.method_description }}} |
| 124 | </td> |
| 125 | <td class="wc-shipping-zone-actions"> |
| 126 | <div> |
| 127 | <a class="wc-shipping-zone-method-settings wc-shipping-zone-action-edit" href="admin.php?page=wc-settings&tab=shipping&instance_id={{ data.instance_id }}"><?php esc_html_e( 'Edit', 'woocommerce' ); ?></a> | <a href="#" class="wc-shipping-zone-method-delete wc-shipping-zone-actions"><?php esc_html_e( 'Delete', 'woocommerce' ); ?></a> |
| 128 | </div> |
| 129 | </td> |
| 130 | </tr> |
| 131 | </script> |
| 132 | |
| 133 | <script type="text/template" id="tmpl-wc-modal-shipping-method-settings"> |
| 134 | <div class="wc-backbone-modal wc-backbone-modal-shipping-method-settings"> |
| 135 | <div class="wc-backbone-modal-content"> |
| 136 | <section class="wc-backbone-modal-main" role="main"> |
| 137 | <header class="wc-backbone-modal-header"> |
| 138 | <h1> |
| 139 | <?php |
| 140 | printf( |
| 141 | /* translators: %s: shipping method title */ |
| 142 | esc_html__( 'Set up %s', 'woocommerce' ), |
| 143 | '{{{ data.method.method_title.toLowerCase() }}}' |
| 144 | ); |
| 145 | ?> |
| 146 | </h1> |
| 147 | <button class="modal-close modal-close-link dashicons dashicons-no-alt"> |
| 148 | <span class="screen-reader-text"><?php esc_html_e( 'Close modal panel', 'woocommerce' ); ?></span> |
| 149 | </button> |
| 150 | </header> |
| 151 | <article class="wc-modal-shipping-method-settings" data-id="{{{ data.instance_id }}}" data-status="{{{ data.status }}}" data-shipping-classes-count="<?php echo count( WC()->shipping()->get_shipping_classes() ); ?>"> |
| 152 | <form action="" method="post"> |
| 153 | {{{ data.method.settings_html }}} |
| 154 | <input type="hidden" name="instance_id" value="{{{ data.instance_id }}}" /> |
| 155 | </form> |
| 156 | <a class="wc-shipping-method-add-class-costs" style="display:none;" target="_blank" href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings&tab=shipping§ion=classes' ) ); ?>"><?php esc_html_e( 'Add shipping class costs', 'woocommerce' ); ?></a> |
| 157 | </article> |
| 158 | <footer> |
| 159 | <div class="inner"> |
| 160 | <div class="wc-backbone-modal-buttons"> |
| 161 | <button id="btn-back" class="button button-large wc-backbone-modal-back-{{ data.status === 'new' ? 'active' : 'inactive' }}"><?php esc_html_e( 'Back', 'woocommerce' ); ?></button> |
| 162 | <button id="btn-ok" data-status='{{ data.status }}' class="button button-primary button-large"> |
| 163 | <div class="wc-backbone-modal-action-{{ data.status === 'new' ? 'active' : 'inactive' }}"><?php esc_html_e( 'Create and save', 'woocommerce' ); ?></div> |
| 164 | <div class="wc-backbone-modal-action-{{ data.status === 'existing' ? 'active' : 'inactive' }}"><?php esc_html_e( 'Save', 'woocommerce' ); ?></div> |
| 165 | </button> |
| 166 | </div> |
| 167 | <div class="wc-shipping-zone-method-modal-info wc-shipping-zone-method-modal-info-{{ data.status === 'existing' ? 'inactive' : 'active' }}"><?php esc_html_e( 'STEP 2 OF 2', 'woocommerce' ); ?></div> |
| 168 | </div> |
| 169 | </footer> |
| 170 | </section> |
| 171 | </div> |
| 172 | </div> |
| 173 | <div class="wc-backbone-modal-backdrop modal-close"></div> |
| 174 | </script> |
| 175 | |
| 176 | <script type="text/template" id="tmpl-wc-modal-add-shipping-method"> |
| 177 | <div class="wc-backbone-modal wc-backbone-modal-add-shipping-method"> |
| 178 | <div class="wc-backbone-modal-content"> |
| 179 | <section class="wc-backbone-modal-main" role="main"> |
| 180 | <header class="wc-backbone-modal-header"> |
| 181 | <h1><?php esc_html_e( 'Create shipping method', 'woocommerce' ); ?></h1> |
| 182 | <button class="modal-close modal-close-link dashicons dashicons-no-alt"> |
| 183 | <span class="screen-reader-text"><?php esc_html_e( 'Close modal panel', 'woocommerce' ); ?></span> |
| 184 | </button> |
| 185 | </header> |
| 186 | <article> |
| 187 | <form action="" method="post"> |
| 188 | <fieldset class="wc-shipping-zone-method-selector"> |
| 189 | <legend class="screen-reader-text"><?php esc_html_e( 'Choose the shipping method you wish to add. Only shipping methods which support zones are listed.', 'woocommerce' ); ?></legend> |
| 190 | <?php |
| 191 | $methods = WC()->shipping()->load_shipping_methods(); |
| 192 | |
| 193 | $methods_placed_in_order = array(); |
| 194 | $first_methods_ids = array( 'free_shipping', 'flat_rate', 'local_pickup' ); |
| 195 | |
| 196 | foreach ( $first_methods_ids as $first_method_id ) { |
| 197 | foreach ( $methods as $key => $obj ) { |
| 198 | if ( $obj->id === $first_method_id ) { |
| 199 | $methods_placed_in_order[] = $obj; |
| 200 | unset( $methods[ $key ] ); |
| 201 | break; |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | $methods_placed_in_order = array_merge( $methods_placed_in_order, array_values( $methods ) ); |
| 207 | |
| 208 | foreach ( $methods_placed_in_order as $method ) { |
| 209 | if ( CartCheckoutUtils::is_checkout_block_default() && ! ShippingController::is_legacy_local_pickup_active() && 'local_pickup' === $method->id ) { |
| 210 | continue; |
| 211 | } |
| 212 | |
| 213 | if ( ! $method->supports( 'shipping-zones' ) ) { |
| 214 | continue; |
| 215 | } |
| 216 | |
| 217 | echo '<div class="wc-shipping-zone-method-input"><input type="radio" value="' . esc_attr( $method->id ) . '" id="' . esc_attr( $method->id ) . '" name="add_method_id"/><label for="' . esc_attr( $method->id ) . '">' . esc_html( $method->get_method_title() ) . '<span class="dashicons dashicons-yes"></span></label></div>'; |
| 218 | } |
| 219 | |
| 220 | echo '<div class="wc-shipping-zone-method-input-help-text-container">'; |
| 221 | |
| 222 | foreach ( $methods_placed_in_order as $method ) { |
| 223 | if ( ! $method->supports( 'shipping-zones' ) ) { |
| 224 | continue; |
| 225 | } |
| 226 | |
| 227 | echo '<div id=' . esc_attr( $method->id ) . '-description class="wc-shipping-zone-method-input-help-text"><span>' . wp_kses_post( wpautop( $method->get_method_description() ) ) . '</span></div>'; |
| 228 | } |
| 229 | |
| 230 | if ( CartCheckoutUtils::is_checkout_block_default() ) { |
| 231 | echo '<p class="wc-shipping-legacy-local-pickup-help-text-container">'; |
| 232 | |
| 233 | if ( ShippingController::is_legacy_local_pickup_active() ) { |
| 234 | printf( |
| 235 | wp_kses( |
| 236 | /* translators: %s: Local pickup settings page URL. */ |
| 237 | __( 'Explore a new enhanced delivery method that allows you to easily offer one or more pickup locations to your customers in the <a href="%s">Local pickup settings page</a>.', 'woocommerce' ), |
| 238 | array( 'a' => array( 'href' => array() ) ) |
| 239 | ), |
| 240 | esc_url( admin_url( 'admin.php?page=wc-settings&tab=shipping§ion=pickup_location' ) ) |
| 241 | ); |
| 242 | |
| 243 | } else { |
| 244 | /* translators: %s: Local pickup settings page URL. */ |
| 245 | $message = __( 'Local pickup: Set up pickup locations in the <a href="%s">Local pickup settings page</a>.', 'woocommerce' ); |
| 246 | if ( LocalPickupUtils::is_local_pickup_enabled() ) { |
| 247 | /* translators: %s: Local pickup settings page URL. */ |
| 248 | $message = __( 'Local pickup: Manage existing pickup locations in the <a href="%s">Local pickup settings page</a>.', 'woocommerce' ); |
| 249 | } |
| 250 | printf( |
| 251 | wp_kses( |
| 252 | $message, |
| 253 | array( 'a' => array( 'href' => array() ) ) |
| 254 | ), |
| 255 | esc_url( admin_url( 'admin.php?page=wc-settings&tab=shipping§ion=pickup_location' ) ) |
| 256 | ); |
| 257 | } |
| 258 | |
| 259 | echo '</p>'; |
| 260 | } |
| 261 | |
| 262 | echo '</div>'; |
| 263 | |
| 264 | ?> |
| 265 | </fieldset> |
| 266 | </form> |
| 267 | </article> |
| 268 | <footer> |
| 269 | <div class="inner"> |
| 270 | <div class="wc-backbone-modal-buttons"> |
| 271 | <button id="btn-next" disabled class="button button-primary button-large disabled"><?php esc_html_e( 'Continue', 'woocommerce' ); ?></button> |
| 272 | </div> |
| 273 | <div class="wc-shipping-zone-method-modal-info"><?php esc_html_e( 'STEP 1 OF 2', 'woocommerce' ); ?></div> |
| 274 | </div> |
| 275 | </footer> |
| 276 | </section> |
| 277 | </div> |
| 278 | </div> |
| 279 | <div class="wc-backbone-modal-backdrop modal-close"></div> |
| 280 | </script> |
| 281 |