Aucune description

class-wc-settings-general.php 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <?php
  2. /**
  3. * WooCommerce General Settings
  4. *
  5. * @package WooCommerce\Admin
  6. */
  7. defined( 'ABSPATH' ) || exit;
  8. if ( class_exists( 'WC_Settings_General', false ) ) {
  9. return new WC_Settings_General();
  10. }
  11. /**
  12. * WC_Admin_Settings_General.
  13. */
  14. class WC_Settings_General extends WC_Settings_Page {
  15. /**
  16. * Constructor.
  17. */
  18. public function __construct() {
  19. $this->id = 'general';
  20. $this->label = __( 'General', 'woocommerce' );
  21. parent::__construct();
  22. }
  23. /**
  24. * Get settings or the default section.
  25. *
  26. * @return array
  27. */
  28. protected function get_settings_for_default_section() {
  29. $currency_code_options = get_woocommerce_currencies();
  30. foreach ( $currency_code_options as $code => $name ) {
  31. $currency_code_options[ $code ] = $name . ' (' . get_woocommerce_currency_symbol( $code ) . ')';
  32. }
  33. $settings =
  34. array(
  35. array(
  36. 'title' => __( 'Store Address', 'woocommerce' ),
  37. 'type' => 'title',
  38. 'desc' => __( 'This is where your business is located. Tax rates and shipping rates will use this address.', 'woocommerce' ),
  39. 'id' => 'store_address',
  40. ),
  41. array(
  42. 'title' => __( 'Address line 1', 'woocommerce' ),
  43. 'desc' => __( 'The street address for your business location.', 'woocommerce' ),
  44. 'id' => 'woocommerce_store_address',
  45. 'default' => '',
  46. 'type' => 'text',
  47. 'desc_tip' => true,
  48. ),
  49. array(
  50. 'title' => __( 'Address line 2', 'woocommerce' ),
  51. 'desc' => __( 'An additional, optional address line for your business location.', 'woocommerce' ),
  52. 'id' => 'woocommerce_store_address_2',
  53. 'default' => '',
  54. 'type' => 'text',
  55. 'desc_tip' => true,
  56. ),
  57. array(
  58. 'title' => __( 'City', 'woocommerce' ),
  59. 'desc' => __( 'The city in which your business is located.', 'woocommerce' ),
  60. 'id' => 'woocommerce_store_city',
  61. 'default' => '',
  62. 'type' => 'text',
  63. 'desc_tip' => true,
  64. ),
  65. array(
  66. 'title' => __( 'Country / State', 'woocommerce' ),
  67. 'desc' => __( 'The country and state or province, if any, in which your business is located.', 'woocommerce' ),
  68. 'id' => 'woocommerce_default_country',
  69. 'default' => 'US:CA',
  70. 'type' => 'single_select_country',
  71. 'desc_tip' => true,
  72. ),
  73. array(
  74. 'title' => __( 'Postcode / ZIP', 'woocommerce' ),
  75. 'desc' => __( 'The postal code, if any, in which your business is located.', 'woocommerce' ),
  76. 'id' => 'woocommerce_store_postcode',
  77. 'css' => 'min-width:50px;',
  78. 'default' => '',
  79. 'type' => 'text',
  80. 'desc_tip' => true,
  81. ),
  82. array(
  83. 'type' => 'sectionend',
  84. 'id' => 'store_address',
  85. ),
  86. array(
  87. 'title' => __( 'General options', 'woocommerce' ),
  88. 'type' => 'title',
  89. 'desc' => '',
  90. 'id' => 'general_options',
  91. ),
  92. array(
  93. 'title' => __( 'Selling location(s)', 'woocommerce' ),
  94. 'desc' => __( 'This option lets you limit which countries you are willing to sell to.', 'woocommerce' ),
  95. 'id' => 'woocommerce_allowed_countries',
  96. 'default' => 'all',
  97. 'type' => 'select',
  98. 'class' => 'wc-enhanced-select',
  99. 'css' => 'min-width: 350px;',
  100. 'desc_tip' => true,
  101. 'options' => array(
  102. 'all' => __( 'Sell to all countries', 'woocommerce' ),
  103. 'all_except' => __( 'Sell to all countries, except for&hellip;', 'woocommerce' ),
  104. 'specific' => __( 'Sell to specific countries', 'woocommerce' ),
  105. ),
  106. ),
  107. array(
  108. 'title' => __( 'Sell to all countries, except for&hellip;', 'woocommerce' ),
  109. 'desc' => '',
  110. 'id' => 'woocommerce_all_except_countries',
  111. 'css' => 'min-width: 350px;',
  112. 'default' => '',
  113. 'type' => 'multi_select_countries',
  114. ),
  115. array(
  116. 'title' => __( 'Sell to specific countries', 'woocommerce' ),
  117. 'desc' => '',
  118. 'id' => 'woocommerce_specific_allowed_countries',
  119. 'css' => 'min-width: 350px;',
  120. 'default' => '',
  121. 'type' => 'multi_select_countries',
  122. ),
  123. array(
  124. 'title' => __( 'Shipping location(s)', 'woocommerce' ),
  125. 'desc' => __( 'Choose which countries you want to ship to, or choose to ship to all locations you sell to.', 'woocommerce' ),
  126. 'id' => 'woocommerce_ship_to_countries',
  127. 'default' => '',
  128. 'type' => 'select',
  129. 'class' => 'wc-enhanced-select',
  130. 'desc_tip' => true,
  131. 'options' => array(
  132. '' => __( 'Ship to all countries you sell to', 'woocommerce' ),
  133. 'all' => __( 'Ship to all countries', 'woocommerce' ),
  134. 'specific' => __( 'Ship to specific countries only', 'woocommerce' ),
  135. 'disabled' => __( 'Disable shipping &amp; shipping calculations', 'woocommerce' ),
  136. ),
  137. ),
  138. array(
  139. 'title' => __( 'Ship to specific countries', 'woocommerce' ),
  140. 'desc' => '',
  141. 'id' => 'woocommerce_specific_ship_to_countries',
  142. 'css' => '',
  143. 'default' => '',
  144. 'type' => 'multi_select_countries',
  145. ),
  146. array(
  147. 'title' => __( 'Default customer location', 'woocommerce' ),
  148. 'id' => 'woocommerce_default_customer_address',
  149. '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' ),
  150. 'default' => 'base',
  151. 'type' => 'select',
  152. 'class' => 'wc-enhanced-select',
  153. 'options' => array(
  154. '' => __( 'No location by default', 'woocommerce' ),
  155. 'base' => __( 'Shop base address', 'woocommerce' ),
  156. 'geolocation' => __( 'Geolocate', 'woocommerce' ),
  157. 'geolocation_ajax' => __( 'Geolocate (with page caching support)', 'woocommerce' ),
  158. ),
  159. ),
  160. array(
  161. 'title' => __( 'Enable taxes', 'woocommerce' ),
  162. 'desc' => __( 'Enable tax rates and calculations', 'woocommerce' ),
  163. 'id' => 'woocommerce_calc_taxes',
  164. 'default' => 'no',
  165. 'type' => 'checkbox',
  166. 'desc_tip' => __( 'Rates will be configurable and taxes will be calculated during checkout.', 'woocommerce' ),
  167. ),
  168. array(
  169. 'title' => __( 'Enable coupons', 'woocommerce' ),
  170. 'desc' => __( 'Enable the use of coupon codes', 'woocommerce' ),
  171. 'id' => 'woocommerce_enable_coupons',
  172. 'default' => 'yes',
  173. 'type' => 'checkbox',
  174. 'checkboxgroup' => 'start',
  175. 'show_if_checked' => 'option',
  176. 'desc_tip' => __( 'Coupons can be applied from the cart and checkout pages.', 'woocommerce' ),
  177. ),
  178. array(
  179. 'desc' => __( 'Calculate coupon discounts sequentially', 'woocommerce' ),
  180. 'id' => 'woocommerce_calc_discounts_sequentially',
  181. 'default' => 'no',
  182. 'type' => 'checkbox',
  183. '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' ),
  184. 'show_if_checked' => 'yes',
  185. 'checkboxgroup' => 'end',
  186. 'autoload' => false,
  187. ),
  188. array(
  189. 'type' => 'sectionend',
  190. 'id' => 'general_options',
  191. ),
  192. array(
  193. 'title' => __( 'Currency options', 'woocommerce' ),
  194. 'type' => 'title',
  195. 'desc' => __( 'The following options affect how prices are displayed on the frontend.', 'woocommerce' ),
  196. 'id' => 'pricing_options',
  197. ),
  198. array(
  199. 'title' => __( 'Currency', 'woocommerce' ),
  200. 'desc' => __( 'This controls what currency prices are listed at in the catalog and which currency gateways will take payments in.', 'woocommerce' ),
  201. 'id' => 'woocommerce_currency',
  202. 'default' => 'USD',
  203. 'type' => 'select',
  204. 'class' => 'wc-enhanced-select',
  205. 'desc_tip' => true,
  206. 'options' => $currency_code_options,
  207. ),
  208. array(
  209. 'title' => __( 'Currency position', 'woocommerce' ),
  210. 'desc' => __( 'This controls the position of the currency symbol.', 'woocommerce' ),
  211. 'id' => 'woocommerce_currency_pos',
  212. 'class' => 'wc-enhanced-select',
  213. 'default' => 'left',
  214. 'type' => 'select',
  215. 'options' => array(
  216. 'left' => __( 'Left', 'woocommerce' ),
  217. 'right' => __( 'Right', 'woocommerce' ),
  218. 'left_space' => __( 'Left with space', 'woocommerce' ),
  219. 'right_space' => __( 'Right with space', 'woocommerce' ),
  220. ),
  221. 'desc_tip' => true,
  222. ),
  223. array(
  224. 'title' => __( 'Thousand separator', 'woocommerce' ),
  225. 'desc' => __( 'This sets the thousand separator of displayed prices.', 'woocommerce' ),
  226. 'id' => 'woocommerce_price_thousand_sep',
  227. 'css' => 'width:50px;',
  228. 'default' => ',',
  229. 'type' => 'text',
  230. 'desc_tip' => true,
  231. ),
  232. array(
  233. 'title' => __( 'Decimal separator', 'woocommerce' ),
  234. 'desc' => __( 'This sets the decimal separator of displayed prices.', 'woocommerce' ),
  235. 'id' => 'woocommerce_price_decimal_sep',
  236. 'css' => 'width:50px;',
  237. 'default' => '.',
  238. 'type' => 'text',
  239. 'desc_tip' => true,
  240. ),
  241. array(
  242. 'title' => __( 'Number of decimals', 'woocommerce' ),
  243. 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'woocommerce' ),
  244. 'id' => 'woocommerce_price_num_decimals',
  245. 'css' => 'width:50px;',
  246. 'default' => '2',
  247. 'desc_tip' => true,
  248. 'type' => 'number',
  249. 'custom_attributes' => array(
  250. 'min' => 0,
  251. 'step' => 1,
  252. ),
  253. ),
  254. array(
  255. 'type' => 'sectionend',
  256. 'id' => 'pricing_options',
  257. ),
  258. );
  259. return apply_filters( 'woocommerce_general_settings', $settings );
  260. }
  261. /**
  262. * Output a color picker input box.
  263. *
  264. * @param mixed $name Name of input.
  265. * @param string $id ID of input.
  266. * @param mixed $value Value of input.
  267. * @param string $desc (default: '') Description for input.
  268. */
  269. public function color_picker( $name, $id, $value, $desc = '' ) {
  270. echo '<div class="color_box">' . wc_help_tip( $desc ) . '
  271. <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>
  272. </div>';
  273. }
  274. }
  275. return new WC_Settings_General();