WC_Settings_General

WC_Admin_Settings_General.

Defined (1)

The class is defined in the following location(s).

/includes/admin/settings/class-wc-settings-general.php  
  1. class WC_Settings_General extends WC_Settings_Page { 
  2.  
  3. /** 
  4. * Constructor. 
  5. */ 
  6. public function __construct() { 
  7.  
  8. $this->id = 'general'; 
  9. $this->label = __( 'General', 'woocommerce' ); 
  10.  
  11. add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); 
  12. add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) ); 
  13. add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) ); 
  14.  
  15. /** 
  16. * Get settings array. 
  17. * @return array 
  18. */ 
  19. public function get_settings() { 
  20.  
  21. $currency_code_options = get_woocommerce_currencies(); 
  22.  
  23. foreach ( $currency_code_options as $code => $name ) { 
  24. $currency_code_options[ $code ] = $name . ' (' . get_woocommerce_currency_symbol( $code ) . ')'; 
  25.  
  26. $settings = apply_filters( 'woocommerce_general_settings', array( 
  27.  
  28. array( 'title' => __( 'General options', 'woocommerce' ), 'type' => 'title', 'desc' => '', 'id' => 'general_options' ),  
  29.  
  30. array( 
  31. 'title' => __( 'Base location', 'woocommerce' ),  
  32. 'desc' => __( 'This is the base location for your business. Tax rates will be based on this country.', 'woocommerce' ),  
  33. 'id' => 'woocommerce_default_country',  
  34. 'css' => 'min-width:350px;',  
  35. 'default' => 'GB',  
  36. 'type' => 'single_select_country',  
  37. 'desc_tip' => true,  
  38. ),  
  39.  
  40. array( 
  41. 'title' => __( 'Selling location(s)', 'woocommerce' ),  
  42. 'desc' => __( 'This option lets you limit which countries you are willing to sell to.', 'woocommerce' ),  
  43. 'id' => 'woocommerce_allowed_countries',  
  44. 'default' => 'all',  
  45. 'type' => 'select',  
  46. 'class' => 'wc-enhanced-select',  
  47. 'css' => 'min-width: 350px;',  
  48. 'desc_tip' => true,  
  49. 'options' => array( 
  50. 'all' => __( 'Sell to all countries', 'woocommerce' ),  
  51. 'all_except' => __( 'Sell to all countries, except for…', 'woocommerce' ),  
  52. 'specific' => __( 'Sell to specific countries', 'woocommerce' ),  
  53. ),  
  54. ),  
  55.  
  56. array( 
  57. 'title' => __( 'Sell to all countries, except for…', 'woocommerce' ),  
  58. 'desc' => '',  
  59. 'id' => 'woocommerce_all_except_countries',  
  60. 'css' => 'min-width: 350px;',  
  61. 'default' => '',  
  62. 'type' => 'multi_select_countries',  
  63. ),  
  64.  
  65. array( 
  66. 'title' => __( 'Sell to specific countries', 'woocommerce' ),  
  67. 'desc' => '',  
  68. 'id' => 'woocommerce_specific_allowed_countries',  
  69. 'css' => 'min-width: 350px;',  
  70. 'default' => '',  
  71. 'type' => 'multi_select_countries',  
  72. ),  
  73.  
  74. array( 
  75. 'title' => __( 'Shipping location(s)', 'woocommerce' ),  
  76. 'desc' => __( 'Choose which countries you want to ship to, or choose to ship to all locations you sell to.', 'woocommerce' ),  
  77. 'id' => 'woocommerce_ship_to_countries',  
  78. 'default' => '',  
  79. 'type' => 'select',  
  80. 'class' => 'wc-enhanced-select',  
  81. 'desc_tip' => true,  
  82. 'options' => array( 
  83. '' => __( 'Ship to all countries you sell to', 'woocommerce' ),  
  84. 'all' => __( 'Ship to all countries', 'woocommerce' ),  
  85. 'specific' => __( 'Ship to specific countries only', 'woocommerce' ),  
  86. 'disabled' => __( 'Disable shipping & shipping calculations', 'woocommerce' ),  
  87. ),  
  88. ),  
  89.  
  90. array( 
  91. 'title' => __( 'Ship to specific countries', 'woocommerce' ),  
  92. 'desc' => '',  
  93. 'id' => 'woocommerce_specific_ship_to_countries',  
  94. 'css' => '',  
  95. 'default' => '',  
  96. 'type' => 'multi_select_countries',  
  97. ),  
  98.  
  99. array( 
  100. 'title' => __( 'Default customer location', 'woocommerce' ),  
  101. 'id' => 'woocommerce_default_customer_address',  
  102. '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' ),  
  103. 'default' => 'geolocation',  
  104. 'type' => 'select',  
  105. 'class' => 'wc-enhanced-select',  
  106. 'options' => array( 
  107. '' => __( 'No location by default', 'woocommerce' ),  
  108. 'base' => __( 'Shop base address', 'woocommerce' ),  
  109. 'geolocation' => __( 'Geolocate', 'woocommerce' ),  
  110. 'geolocation_ajax' => __( 'Geolocate (with page caching support)', 'woocommerce' ),  
  111. ),  
  112. ),  
  113.  
  114. array( 
  115. 'title' => __( 'Enable taxes', 'woocommerce' ),  
  116. 'desc' => __( 'Enable taxes and tax calculations', 'woocommerce' ),  
  117. 'id' => 'woocommerce_calc_taxes',  
  118. 'default' => 'no',  
  119. 'type' => 'checkbox',  
  120. ),  
  121.  
  122. array( 
  123. 'title' => __( 'Store notice', 'woocommerce' ),  
  124. 'desc' => __( 'Enable site-wide store notice text', 'woocommerce' ),  
  125. 'id' => 'woocommerce_demo_store',  
  126. 'default' => 'no',  
  127. 'type' => 'checkbox',  
  128. ),  
  129.  
  130. array( 
  131. 'title' => __( 'Store notice text', 'woocommerce' ),  
  132. 'desc' => '',  
  133. 'id' => 'woocommerce_demo_store_notice',  
  134. 'default' => __( 'This is a demo store for testing purposes — no orders shall be fulfilled.', 'woocommerce' ),  
  135. 'type' => 'textarea',  
  136. 'css' => 'width:350px; height: 65px;',  
  137. 'autoload' => false,  
  138. ),  
  139.  
  140. array( 'type' => 'sectionend', 'id' => 'general_options' ),  
  141.  
  142. array( 'title' => __( 'Currency options', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'The following options affect how prices are displayed on the frontend.', 'woocommerce' ), 'id' => 'pricing_options' ),  
  143.  
  144. array( 
  145. 'title' => __( 'Currency', 'woocommerce' ),  
  146. 'desc' => __( 'This controls what currency prices are listed at in the catalog and which currency gateways will take payments in.', 'woocommerce' ),  
  147. 'id' => 'woocommerce_currency',  
  148. 'css' => 'min-width:350px;',  
  149. 'default' => 'GBP',  
  150. 'type' => 'select',  
  151. 'class' => 'wc-enhanced-select',  
  152. 'desc_tip' => true,  
  153. 'options' => $currency_code_options,  
  154. ),  
  155.  
  156. array( 
  157. 'title' => __( 'Currency position', 'woocommerce' ),  
  158. 'desc' => __( 'This controls the position of the currency symbol.', 'woocommerce' ),  
  159. 'id' => 'woocommerce_currency_pos',  
  160. 'css' => 'min-width:350px;',  
  161. 'class' => 'wc-enhanced-select',  
  162. 'default' => 'left',  
  163. 'type' => 'select',  
  164. 'options' => array( 
  165. 'left' => __( 'Left', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . '99.99)',  
  166. 'right' => __( 'Right', 'woocommerce' ) . ' (99.99' . get_woocommerce_currency_symbol() . ')',  
  167. 'left_space' => __( 'Left with space', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ' 99.99)',  
  168. 'right_space' => __( 'Right with space', 'woocommerce' ) . ' (99.99 ' . get_woocommerce_currency_symbol() . ')',  
  169. ),  
  170. 'desc_tip' => true,  
  171. ),  
  172.  
  173. array( 
  174. 'title' => __( 'Thousand separator', 'woocommerce' ),  
  175. 'desc' => __( 'This sets the thousand separator of displayed prices.', 'woocommerce' ),  
  176. 'id' => 'woocommerce_price_thousand_sep',  
  177. 'css' => 'width:50px;',  
  178. 'default' => ', ',  
  179. 'type' => 'text',  
  180. 'desc_tip' => true,  
  181. ),  
  182.  
  183. array( 
  184. 'title' => __( 'Decimal separator', 'woocommerce' ),  
  185. 'desc' => __( 'This sets the decimal separator of displayed prices.', 'woocommerce' ),  
  186. 'id' => 'woocommerce_price_decimal_sep',  
  187. 'css' => 'width:50px;',  
  188. 'default' => '.',  
  189. 'type' => 'text',  
  190. 'desc_tip' => true,  
  191. ),  
  192.  
  193. array( 
  194. 'title' => __( 'Number of decimals', 'woocommerce' ),  
  195. 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'woocommerce' ),  
  196. 'id' => 'woocommerce_price_num_decimals',  
  197. 'css' => 'width:50px;',  
  198. 'default' => '2',  
  199. 'desc_tip' => true,  
  200. 'type' => 'number',  
  201. 'custom_attributes' => array( 
  202. 'min' => 0,  
  203. 'step' => 1,  
  204. ),  
  205. ),  
  206.  
  207. array( 'type' => 'sectionend', 'id' => 'pricing_options' ),  
  208.  
  209. ) ); 
  210.  
  211. return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings ); 
  212.  
  213. /** 
  214. * Output a color picker input box. 
  215. * @param mixed $name 
  216. * @param string $id 
  217. * @param mixed $value 
  218. * @param string $desc (default: '') 
  219. */ 
  220. public function color_picker( $name, $id, $value, $desc = '' ) { 
  221. echo '<div class="color_box">' . wc_help_tip( $desc ) . ' 
  222. <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> 
  223. </div>'; 
  224.  
  225. /** 
  226. * Save settings. 
  227. */ 
  228. public function save() { 
  229. $settings = $this->get_settings(); 
  230.  
  231. WC_Admin_Settings::save_fields( $settings );