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rc.2 3.1.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / admin / settings / class-wc-settings-general.php
woocommerce / includes / admin / settings Last commit date
views 1 month ago class-wc-settings-accounts.php 5 months ago class-wc-settings-advanced.php 1 month ago class-wc-settings-checkout.php 5 years ago class-wc-settings-emails.php 1 month ago class-wc-settings-general.php 1 month ago class-wc-settings-integrations.php 1 year ago class-wc-settings-page.php 1 week ago class-wc-settings-payment-gateways.php 1 week ago class-wc-settings-point-of-sale.php 3 months ago class-wc-settings-products.php 1 month ago class-wc-settings-shipping.php 3 months ago class-wc-settings-site-visibility.php 2 years ago class-wc-settings-tax.php 5 months ago
class-wc-settings-general.php
458 lines
1 <?php
2 /**
3 * WooCommerce General Settings
4 *
5 * @package WooCommerce\Admin
6 */
7
8 use Automattic\WooCommerce\Admin\Features\Features;
9 use Automattic\WooCommerce\Enums\DefaultCustomerAddress;
10 use Automattic\WooCommerce\Internal\AddressProvider\AddressProviderController;
11
12 defined( 'ABSPATH' ) || exit;
13
14 /*
15 * Pre-load the enum file because the in-process Jetpack autoloader classmap is
16 * captured at request start by the pre-upgrade plugin version, so during a same-
17 * request in-place upgrade it will not contain new src/Enums/* classes added in
18 * the new version. Without this, the DefaultCustomerAddress::* references below
19 * would trigger an autoloader miss and a "Class not found" fatal during the
20 * upgrade-completion iframe of /wp-admin/update.php.
21 *
22 * The class_exists() guard (with autoload disabled) matches the defensive
23 * pattern used elsewhere in includes/, e.g. class-wc-gateway-paypal.php, and
24 * keeps this safe under opcache.preload or any other mechanism that may have
25 * already defined the class before the file is included.
26 *
27 * The architectural fix lives in https://github.com/woocommerce/woocommerce/issues/54657.
28 */
29 if ( ! class_exists( '\Automattic\WooCommerce\Enums\DefaultCustomerAddress', false ) ) {
30 require_once dirname( WC_PLUGIN_FILE ) . '/src/Enums/DefaultCustomerAddress.php';
31 }
32
33 if ( class_exists( 'WC_Settings_General', false ) ) {
34 return new WC_Settings_General();
35 }
36
37 /**
38 * WC_Admin_Settings_General.
39 */
40 class WC_Settings_General extends WC_Settings_Page {
41
42 /**
43 * Constructor.
44 */
45 public function __construct() {
46 $this->id = 'general';
47 $this->label = __( 'General', 'woocommerce' );
48
49 parent::__construct();
50 }
51
52 /**
53 * Setting page icon.
54 *
55 * @var string
56 */
57 public $icon = 'cog';
58
59 /**
60 * Get settings or the default section.
61 *
62 * @return array
63 */
64 protected function get_settings_for_default_section() {
65
66 $currency_code_options = get_woocommerce_currencies();
67
68 foreach ( $currency_code_options as $code => $name ) {
69 $currency_code_options[ $code ] = $name . ' (' . get_woocommerce_currency_symbol( $code ) . ') — ' . esc_html( $code );
70 }
71
72 $address_autocomplete_preferred_provider_setting = array();
73 $address_autocomplete_setting_desc_tip = __( 'Suggest full addresses to customers as they type.', 'woocommerce' );
74
75 // This is in a try because getting the class from the container may fail if the class is not available.
76 // If it fails, these settings should not be shown as the feature is not available.
77 try {
78 $address_provider_class = wc_get_container()->get( AddressProviderController::class );
79 $address_autocomplete_providers = $address_provider_class->get_providers();
80 $address_autocomplete_available = ! empty( $address_autocomplete_providers );
81
82 if ( ! $address_autocomplete_available ) {
83 // translators: %s: WooPayments URL.
84 $address_autocomplete_setting_desc_tip .= ' ' . sprintf( __( 'Requires a plugin with predictive address search support (e.g. <a href="%s" target="_blank">WooPayments</a>).', 'woocommerce' ), 'https://woocommerce.com/products/woocommerce-payments/' );
85 }
86
87 $enable_address_autocomplete_setting = array(
88 'id' => 'woocommerce_address_autocomplete_enabled',
89 'desc' => __( 'Enable predictive address search', 'woocommerce' ),
90 'name' => __( 'Address autocomplete', 'woocommerce' ),
91 'type' => 'checkbox',
92 'disabled' => ! $address_autocomplete_available,
93 'desc_tip' => $address_autocomplete_setting_desc_tip,
94 'default' => 'no',
95 );
96
97 // If no providers are available, make sure the checkbox is unchecked.
98 if ( ! $address_autocomplete_available ) {
99 $enable_address_autocomplete_setting['value'] = false;
100 }
101
102 if ( count( $address_autocomplete_providers ) > 1 ) {
103 $address_provider_options = array();
104 foreach ( $address_autocomplete_providers as $address_provider ) {
105 $address_provider_options[ $address_provider->id ] = sanitize_text_field( $address_provider->name );
106 }
107 $address_autocomplete_preferred_provider_setting = array(
108 'id' => 'woocommerce_address_autocomplete_provider',
109 'name' => __( 'Preferred address autocomplete provider', 'woocommerce' ),
110 'type' => 'select',
111 'class' => 'wc-enhanced-select',
112 'default' => $address_autocomplete_providers[0]->id ?? '',
113 'options' => $address_provider_options,
114 );
115 }
116 } catch ( \Exception $e ) {
117 // If the class is not available, we don't want to show the setting.
118 wc_get_logger()->log( 'error', 'Error getting address provider class: ' . $e->getMessage() );
119 $enable_address_autocomplete_setting = array();
120 $address_autocomplete_preferred_provider_setting = array();
121 }
122
123 $settings =
124 array(
125
126 array(
127 'title' => __( 'Store Address', 'woocommerce' ),
128 'type' => 'title',
129 'desc' => __( 'This is where your business is located. Tax rates and shipping rates will use this address.', 'woocommerce' ),
130 'id' => 'store_address',
131 'order' => 10,
132 ),
133
134 array(
135 'title' => __( 'Address line 1', 'woocommerce' ),
136 'desc' => __( 'The street address for your business location.', 'woocommerce' ),
137 'id' => 'woocommerce_store_address',
138 'default' => '',
139 'type' => 'text',
140 'desc_tip' => true,
141 ),
142
143 array(
144 'title' => __( 'Address line 2', 'woocommerce' ),
145 'desc' => __( 'An additional, optional address line for your business location.', 'woocommerce' ),
146 'id' => 'woocommerce_store_address_2',
147 'default' => '',
148 'type' => 'text',
149 'desc_tip' => true,
150 ),
151
152 array(
153 'title' => __( 'City', 'woocommerce' ),
154 'desc' => __( 'The city in which your business is located.', 'woocommerce' ),
155 'id' => 'woocommerce_store_city',
156 'default' => '',
157 'type' => 'text',
158 'desc_tip' => true,
159 ),
160
161 array(
162 'title' => __( 'Country / State', 'woocommerce' ),
163 'desc' => __( 'The country and state or province, if any, in which your business is located.', 'woocommerce' ),
164 'id' => 'woocommerce_default_country',
165 'default' => 'US:CA',
166 'type' => 'single_select_country',
167 'desc_tip' => true,
168 ),
169
170 array(
171 'title' => __( 'Postcode / ZIP', 'woocommerce' ),
172 'desc' => __( 'The postal code, if any, in which your business is located.', 'woocommerce' ),
173 'id' => 'woocommerce_store_postcode',
174 'css' => 'min-width:50px;',
175 'default' => '',
176 'type' => 'text',
177 'desc_tip' => true,
178 ),
179
180 array(
181 'type' => 'sectionend',
182 'id' => 'store_address',
183 ),
184
185 array(
186 'title' => __( 'General options', 'woocommerce' ),
187 'type' => 'title',
188 'desc' => '',
189 'id' => 'general_options',
190 'order' => 20,
191 ),
192
193 array(
194 'title' => __( 'Selling location(s)', 'woocommerce' ),
195 'desc' => __( 'This option lets you limit which countries you are willing to sell to.', 'woocommerce' ),
196 'id' => 'woocommerce_allowed_countries',
197 'default' => 'all',
198 'type' => 'select',
199 'class' => 'wc-enhanced-select',
200 'css' => 'min-width: 350px;',
201 'desc_tip' => true,
202 'options' => array(
203 'all' => __( 'Sell to all countries', 'woocommerce' ),
204 'all_except' => __( 'Sell to all countries, except for&hellip;', 'woocommerce' ),
205 'specific' => __( 'Sell to specific countries', 'woocommerce' ),
206 ),
207 ),
208
209 array(
210 'title' => __( 'Sell to all countries, except for&hellip;', 'woocommerce' ),
211 'desc' => '',
212 'id' => 'woocommerce_all_except_countries',
213 'css' => 'min-width: 350px;',
214 'default' => '',
215 'type' => 'multi_select_countries',
216 ),
217
218 array(
219 'title' => __( 'Sell to specific countries', 'woocommerce' ),
220 'desc' => '',
221 'id' => 'woocommerce_specific_allowed_countries',
222 'css' => 'min-width: 350px;',
223 'default' => '',
224 'type' => 'multi_select_countries',
225 ),
226
227 array(
228 'title' => __( 'Shipping location(s)', 'woocommerce' ),
229 'desc' => __( 'Choose which countries you want to ship to, or choose to ship to all locations you sell to.', 'woocommerce' ),
230 'id' => 'woocommerce_ship_to_countries',
231 'default' => '',
232 'type' => 'select',
233 'class' => 'wc-enhanced-select',
234 'desc_tip' => true,
235 'options' => array(
236 '' => __( 'Ship to all countries you sell to', 'woocommerce' ),
237 'all' => __( 'Ship to all countries', 'woocommerce' ),
238 'specific' => __( 'Ship to specific countries only', 'woocommerce' ),
239 'disabled' => __( 'Disable shipping &amp; shipping calculations', 'woocommerce' ),
240 ),
241 ),
242
243 array(
244 'title' => __( 'Ship to specific countries', 'woocommerce' ),
245 'desc' => '',
246 'id' => 'woocommerce_specific_ship_to_countries',
247 'css' => '',
248 'default' => '',
249 'type' => 'multi_select_countries',
250 ),
251
252 array(
253 'title' => __( 'Default customer location', 'woocommerce' ),
254 'id' => 'woocommerce_default_customer_address',
255 'desc_tip' => __( 'This option determines a customers default location. The MaxMind GeoLite Database will be periodically downloaded to your wp-content directory if using geolocation.', 'woocommerce' ),
256 'default' => DefaultCustomerAddress::BASE,
257 'type' => 'select',
258 'class' => 'wc-enhanced-select',
259 'options' => array(
260 DefaultCustomerAddress::NO_DEFAULT => __( 'No location by default', 'woocommerce' ),
261 DefaultCustomerAddress::BASE => __( 'Shop country/region', 'woocommerce' ),
262 DefaultCustomerAddress::GEOLOCATION => __( 'Geolocate', 'woocommerce' ),
263 DefaultCustomerAddress::GEOLOCATION_AJAX => __( 'Geolocate (with page caching support)', 'woocommerce' ),
264 ),
265 ),
266
267 $enable_address_autocomplete_setting,
268
269 $address_autocomplete_preferred_provider_setting,
270
271 array(
272 'type' => 'sectionend',
273 'id' => 'general_options',
274 ),
275
276 array(
277 'title' => __( 'Taxes and coupons', 'woocommerce' ),
278 'type' => 'title',
279 'desc' => __( 'Enable taxes and coupons and configure how they are calculated.', 'woocommerce' ),
280 'id' => 'taxes_and_coupons_options',
281 'order' => 30,
282 ),
283
284 array(
285 'title' => __( 'Enable taxes', 'woocommerce' ),
286 'desc' => __( 'Enable tax rates and calculations', 'woocommerce' ),
287 'id' => 'woocommerce_calc_taxes',
288 'default' => 'no',
289 'type' => 'checkbox',
290 'desc_tip' => __( 'Rates will be configurable and taxes will be calculated during checkout.', 'woocommerce' ),
291 ),
292
293 array(
294 'title' => __( 'Enable coupons', 'woocommerce' ),
295 'desc' => __( 'Enable the use of coupon codes', 'woocommerce' ),
296 'id' => 'woocommerce_enable_coupons',
297 'default' => 'yes',
298 'type' => 'checkbox',
299 'checkboxgroup' => 'start',
300 'show_if_checked' => 'option',
301 'desc_tip' => __( 'Coupons can be applied from the cart and checkout pages.', 'woocommerce' ),
302 ),
303
304 array(
305 'desc' => __( 'Calculate coupon discounts sequentially', 'woocommerce' ),
306 'id' => 'woocommerce_calc_discounts_sequentially',
307 'default' => 'no',
308 'type' => 'checkbox',
309 'desc_tip' => __( 'When applying multiple coupons, apply the first coupon to the full price and the second coupon to the discounted price and so on.', 'woocommerce' ),
310 'show_if_checked' => 'yes',
311 'checkboxgroup' => 'end',
312 'autoload' => false,
313 ),
314
315 array(
316 'type' => 'sectionend',
317 'id' => 'taxes_and_coupons_options',
318 ),
319
320 array(
321 'title' => __( 'Currency options', 'woocommerce' ),
322 'type' => 'title',
323 'desc' => __( 'The following options affect how prices are displayed on the frontend.', 'woocommerce' ),
324 'id' => 'pricing_options',
325 'order' => 40,
326 ),
327
328 array(
329 'title' => __( 'Currency', 'woocommerce' ),
330 'desc' => __( 'This controls what currency prices are listed at in the catalog and which currency gateways will take payments in.', 'woocommerce' ),
331 'id' => 'woocommerce_currency',
332 'default' => 'USD',
333 'type' => 'select',
334 'class' => 'wc-enhanced-select',
335 'desc_tip' => true,
336 'options' => $currency_code_options,
337 ),
338
339 array(
340 'title' => __( 'Currency position', 'woocommerce' ),
341 'desc' => __( 'This controls the position of the currency symbol.', 'woocommerce' ),
342 'id' => 'woocommerce_currency_pos',
343 'class' => 'wc-enhanced-select',
344 'default' => 'left',
345 'type' => 'select',
346 'options' => array(
347 'left' => __( 'Left', 'woocommerce' ),
348 'right' => __( 'Right', 'woocommerce' ),
349 'left_space' => __( 'Left with space', 'woocommerce' ),
350 'right_space' => __( 'Right with space', 'woocommerce' ),
351 ),
352 'desc_tip' => true,
353 ),
354
355 array(
356 'title' => __( 'Thousand separator', 'woocommerce' ),
357 'desc' => __( 'This sets the thousand separator of displayed prices.', 'woocommerce' ),
358 'id' => 'woocommerce_price_thousand_sep',
359 'css' => 'width:50px;',
360 'default' => ',',
361 'type' => 'text',
362 'desc_tip' => true,
363 ),
364
365 array(
366 'title' => __( 'Decimal separator', 'woocommerce' ),
367 'desc' => __( 'This sets the decimal separator of displayed prices.', 'woocommerce' ),
368 'id' => 'woocommerce_price_decimal_sep',
369 'css' => 'width:50px;',
370 'default' => '.',
371 'type' => 'text',
372 'desc_tip' => true,
373 ),
374
375 array(
376 'title' => __( 'Number of decimals', 'woocommerce' ),
377 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'woocommerce' ),
378 'id' => 'woocommerce_price_num_decimals',
379 'css' => 'width:50px;',
380 'default' => '2',
381 'desc_tip' => true,
382 'type' => 'number',
383 'custom_attributes' => array(
384 'min' => 0,
385 'step' => 1,
386 ),
387 ),
388
389 array(
390 'type' => 'sectionend',
391 'id' => 'pricing_options',
392 ),
393 );
394
395 // Remove any empty items from settings array.
396 // e.g. The preferred autocomplete provider setting would be empty if <=1 providers are registered.
397 $settings = array_filter(
398 $settings,
399 function ( $setting ) {
400 return ! empty( $setting );
401 }
402 );
403 return apply_filters( 'woocommerce_general_settings', $settings );
404 }
405
406 /**
407 * Output a color picker input box.
408 *
409 * @param mixed $name Name of input.
410 * @param string $id ID of input.
411 * @param mixed $value Value of input.
412 * @param string $desc (default: '') Description for input.
413 */
414 public function color_picker( $name, $id, $value, $desc = '' ) {
415 echo '<div class="color_box">' . wc_help_tip( $desc ) . '
416 <input name="' . esc_attr( $id ) . '" id="' . esc_attr( $id ) . '" type="text" value="' . esc_attr( $value ) . '" class="colorpick" /> <div id="colorPickerDiv_' . esc_attr( $id ) . '" class="colorpickdiv"></div>
417 </div>';
418 }
419
420 /**
421 * Output settings with additional JS to hide preferred provider if autocomplete is disabled.
422 *
423 * @return void
424 */
425 public function output() {
426 parent::output();
427
428 $handle = 'wc-admin-settings-general';
429 wp_register_script( $handle, '', array(), WC_VERSION, array( 'in_footer' => true ) );
430 wp_enqueue_script( $handle );
431 wp_add_inline_script(
432 $handle,
433 "
434 const preferredProviderInput = document.querySelector( '#woocommerce_address_autocomplete_provider' );
435 const autocompleteEnabledInput = document.querySelector( '#woocommerce_address_autocomplete_enabled' );
436 let preferredProviderRow = null;
437 if ( preferredProviderInput ) {
438 preferredProviderRow = preferredProviderInput.closest( 'tr' );
439 }
440 if ( autocompleteEnabledInput && preferredProviderRow ) {
441 if ( ! autocompleteEnabledInput.checked ) {
442 preferredProviderRow.style.display = 'none';
443 }
444 autocompleteEnabledInput.addEventListener( 'change', function( e ) {
445 if ( e.target.checked ) {
446 preferredProviderRow.style.display = 'table-row';
447 } else {
448 preferredProviderRow.style.display = 'none';
449 }
450 } );
451 }
452 "
453 );
454 }
455 }
456
457 return new WC_Settings_General();
458