2013-07-26 14:36:28 +00:00
< ? php
/**
2015-11-03 13:53:50 +00:00
* WooCommerce General Settings
2013-07-26 14:36:28 +00:00
*
2014-08-31 08:22:03 +00:00
* @ author WooThemes
* @ category Admin
* @ package WooCommerce / Admin
2013-07-26 14:36:28 +00:00
* @ version 2.1 . 0
*/
2014-04-08 22:11:33 +00:00
if ( ! defined ( 'ABSPATH' ) ) {
exit ; // Exit if accessed directly
}
2013-07-26 14:36:28 +00:00
2017-02-16 11:46:01 +00:00
if ( ! class_exists ( 'WC_Settings_General' , false ) ) :
2013-07-26 14:36:28 +00:00
/**
2015-11-03 13:31:20 +00:00
* WC_Admin_Settings_General .
2013-07-26 14:36:28 +00:00
*/
class WC_Settings_General extends WC_Settings_Page {
/**
* Constructor .
*/
public function __construct () {
$this -> id = 'general' ;
$this -> label = __ ( 'General' , 'woocommerce' );
2017-08-12 00:36:35 +00:00
parent :: __construct ();
2013-07-26 14:36:28 +00:00
}
/**
2015-11-03 13:31:20 +00:00
* Get settings array .
2013-07-26 14:36:28 +00:00
*
* @ return array
*/
public function get_settings () {
2014-08-31 08:22:03 +00:00
2013-07-26 14:36:28 +00:00
$currency_code_options = get_woocommerce_currencies ();
2014-04-08 22:11:33 +00:00
foreach ( $currency_code_options as $code => $name ) {
2013-07-26 14:36:28 +00:00
$currency_code_options [ $code ] = $name . ' (' . get_woocommerce_currency_symbol ( $code ) . ')' ;
2014-04-08 22:11:33 +00:00
}
2013-07-26 14:36:28 +00:00
2014-09-12 11:20:06 +00:00
$settings = apply_filters ( 'woocommerce_general_settings' , array (
2013-07-26 14:36:28 +00:00
2017-06-15 16:56:52 +00:00
array (
'title' => __ ( 'Store Address' , 'woocommerce' ),
'type' => 'title' ,
'desc' => __ ( 'This is where your business is located. Tax rates and shipping rates will use this address.' , 'woocommerce' ),
2017-06-30 13:59:45 +00:00
'id' => 'store_address' ,
2017-06-15 16:56:52 +00:00
),
array (
2017-06-19 18:28:42 +00:00
'title' => __ ( 'Address line 1' , 'woocommerce' ),
2017-06-15 16:56:52 +00:00
'desc' => __ ( 'The street address for your business location.' , 'woocommerce' ),
'id' => 'woocommerce_store_address' ,
'default' => '' ,
'type' => 'text' ,
'desc_tip' => true ,
),
array (
2017-06-19 18:28:42 +00:00
'title' => __ ( 'Address line 2' , 'woocommerce' ),
2017-06-15 16:56:52 +00:00
'desc' => __ ( 'An additional, optional address line for your business location.' , 'woocommerce' ),
'id' => 'woocommerce_store_address_2' ,
'default' => '' ,
'type' => 'text' ,
'desc_tip' => true ,
),
2013-07-26 14:36:28 +00:00
array (
2017-06-15 16:56:52 +00:00
'title' => __ ( 'City' , 'woocommerce' ),
'desc' => __ ( 'The city in which your business is located.' , 'woocommerce' ),
'id' => 'woocommerce_store_city' ,
'default' => '' ,
'type' => 'text' ,
'desc_tip' => true ,
),
array (
'title' => __ ( 'Country / State' , 'woocommerce' ),
'desc' => __ ( 'The country and state or province, if any, in which your business is located.' , 'woocommerce' ),
2014-08-31 08:22:03 +00:00
'id' => 'woocommerce_default_country' ,
'default' => 'GB' ,
'type' => 'single_select_country' ,
2016-08-27 06:14:06 +00:00
'desc_tip' => true ,
2013-07-26 14:36:28 +00:00
),
2017-06-15 16:56:52 +00:00
array (
2017-06-19 18:28:42 +00:00
'title' => __ ( 'Postcode / ZIP' , 'woocommerce' ),
2017-06-15 16:56:52 +00:00
'desc' => __ ( 'The postal code, if any, in which your business is located.' , 'woocommerce' ),
'id' => 'woocommerce_store_postcode' ,
'css' => 'min-width:50px;' ,
'default' => '' ,
'type' => 'text' ,
'desc_tip' => true ,
),
array ( 'type' => 'sectionend' , 'id' => 'store_address' ),
array ( 'title' => __ ( 'General options' , 'woocommerce' ), 'type' => 'title' , 'desc' => '' , 'id' => 'general_options' ),
2013-07-26 14:36:28 +00:00
array (
2016-10-12 10:16:30 +00:00
'title' => __ ( 'Selling location(s)' , 'woocommerce' ),
2014-08-31 08:22:03 +00:00
'desc' => __ ( 'This option lets you limit which countries you are willing to sell to.' , 'woocommerce' ),
'id' => 'woocommerce_allowed_countries' ,
'default' => 'all' ,
'type' => 'select' ,
2015-01-09 16:39:10 +00:00
'class' => 'wc-enhanced-select' ,
2014-08-31 08:22:03 +00:00
'css' => 'min-width: 350px;' ,
2016-08-27 06:14:06 +00:00
'desc_tip' => true ,
2014-08-31 08:22:03 +00:00
'options' => array (
2016-10-12 10:16:30 +00:00
'all' => __ ( 'Sell to all countries' , 'woocommerce' ),
'all_except' => __ ( 'Sell to all countries, except for…' , 'woocommerce' ),
'specific' => __ ( 'Sell to specific countries' , 'woocommerce' ),
2016-08-27 01:46:45 +00:00
),
2013-07-26 14:36:28 +00:00
),
2016-04-20 17:55:05 +00:00
array (
2016-10-12 10:16:30 +00:00
'title' => __ ( 'Sell to all countries, except for…' , 'woocommerce' ),
2016-04-20 17:55:05 +00:00
'desc' => '' ,
'id' => 'woocommerce_all_except_countries' ,
'css' => 'min-width: 350px;' ,
'default' => '' ,
2016-08-27 01:46:45 +00:00
'type' => 'multi_select_countries' ,
2016-04-20 17:55:05 +00:00
),
2013-07-26 14:36:28 +00:00
array (
2016-10-12 10:16:30 +00:00
'title' => __ ( 'Sell to specific countries' , 'woocommerce' ),
2014-08-31 08:22:03 +00:00
'desc' => '' ,
'id' => 'woocommerce_specific_allowed_countries' ,
'css' => 'min-width: 350px;' ,
'default' => '' ,
2016-08-27 01:46:45 +00:00
'type' => 'multi_select_countries' ,
2013-07-26 14:36:28 +00:00
),
2015-03-06 14:39:46 +00:00
array (
2016-10-12 10:16:30 +00:00
'title' => __ ( 'Shipping location(s)' , 'woocommerce' ),
2016-01-05 11:23:15 +00:00
'desc' => __ ( 'Choose which countries you want to ship to, or choose to ship to all locations you sell to.' , 'woocommerce' ),
'id' => 'woocommerce_ship_to_countries' ,
'default' => '' ,
'type' => 'select' ,
'class' => 'wc-enhanced-select' ,
'desc_tip' => true ,
'options' => array (
'' => __ ( 'Ship to all countries you sell to' , 'woocommerce' ),
'all' => __ ( 'Ship to all countries' , 'woocommerce' ),
'specific' => __ ( 'Ship to specific countries only' , 'woocommerce' ),
'disabled' => __ ( 'Disable shipping & shipping calculations' , 'woocommerce' ),
2016-08-27 01:46:45 +00:00
),
2016-01-05 11:23:15 +00:00
),
array (
2016-10-12 10:16:30 +00:00
'title' => __ ( 'Ship to specific countries' , 'woocommerce' ),
2016-01-05 11:23:15 +00:00
'desc' => '' ,
'id' => 'woocommerce_specific_ship_to_countries' ,
'css' => '' ,
'default' => '' ,
2016-08-27 01:46:45 +00:00
'type' => 'multi_select_countries' ,
2016-01-05 11:23:15 +00:00
),
array (
2016-10-12 10:16:30 +00:00
'title' => __ ( 'Default customer location' , 'woocommerce' ),
2015-03-06 14:39:46 +00:00
'id' => 'woocommerce_default_customer_address' ,
2016-08-27 06:14:06 +00:00
'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' ),
2015-03-06 14:39:46 +00:00
'default' => 'geolocation' ,
'type' => 'select' ,
'class' => 'wc-enhanced-select' ,
'options' => array (
2016-01-05 11:23:15 +00:00
'' => __ ( 'No location by default' , 'woocommerce' ),
2015-06-17 11:12:49 +00:00
'base' => __ ( 'Shop base address' , 'woocommerce' ),
2015-06-23 11:20:13 +00:00
'geolocation' => __ ( 'Geolocate' , 'woocommerce' ),
'geolocation_ajax' => __ ( 'Geolocate (with page caching support)' , 'woocommerce' ),
2015-03-06 14:39:46 +00:00
),
),
2016-01-05 11:23:15 +00:00
array (
2016-10-12 10:16:30 +00:00
'title' => __ ( 'Enable taxes' , 'woocommerce' ),
2016-01-05 11:23:15 +00:00
'desc' => __ ( 'Enable taxes and tax calculations' , 'woocommerce' ),
'id' => 'woocommerce_calc_taxes' ,
'default' => 'no' ,
2016-08-27 01:46:45 +00:00
'type' => 'checkbox' ,
2016-01-05 11:23:15 +00:00
),
2016-08-27 02:23:54 +00:00
array ( 'type' => 'sectionend' , 'id' => 'general_options' ),
2013-07-26 14:36:28 +00:00
2016-10-12 10:16:30 +00:00
array ( 'title' => __ ( 'Currency options' , 'woocommerce' ), 'type' => 'title' , 'desc' => __ ( 'The following options affect how prices are displayed on the frontend.' , 'woocommerce' ), 'id' => 'pricing_options' ),
2013-07-26 14:36:28 +00:00
array (
2014-08-31 08:22:03 +00:00
'title' => __ ( 'Currency' , 'woocommerce' ),
'desc' => __ ( 'This controls what currency prices are listed at in the catalog and which currency gateways will take payments in.' , 'woocommerce' ),
'id' => 'woocommerce_currency' ,
'default' => 'GBP' ,
'type' => 'select' ,
2015-01-09 16:39:10 +00:00
'class' => 'wc-enhanced-select' ,
2016-08-27 06:14:06 +00:00
'desc_tip' => true ,
2016-08-27 01:46:45 +00:00
'options' => $currency_code_options ,
2013-07-26 14:36:28 +00:00
),
array (
2016-10-12 10:16:30 +00:00
'title' => __ ( 'Currency position' , 'woocommerce' ),
2014-08-31 08:22:03 +00:00
'desc' => __ ( 'This controls the position of the currency symbol.' , 'woocommerce' ),
'id' => 'woocommerce_currency_pos' ,
2015-01-09 16:39:10 +00:00
'class' => 'wc-enhanced-select' ,
2014-08-31 08:22:03 +00:00
'default' => 'left' ,
'type' => 'select' ,
'options' => array (
2017-10-31 12:22:18 +00:00
'left' => __ ( 'Left' , 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol () . '‎99.99)' ,
'right' => __ ( 'Right' , 'woocommerce' ) . ' (99.99' . get_woocommerce_currency_symbol () . '‏)' ,
'left_space' => __ ( 'Left with space' , 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol () . '‎ 99.99)' ,
'right_space' => __ ( 'Right with space' , 'woocommerce' ) . ' (99.99 ' . get_woocommerce_currency_symbol () . '‏)' ,
2013-08-22 10:58:03 +00:00
),
2016-08-27 06:14:06 +00:00
'desc_tip' => true ,
2013-07-26 14:36:28 +00:00
),
array (
2016-10-12 10:16:30 +00:00
'title' => __ ( 'Thousand separator' , 'woocommerce' ),
2014-08-31 08:22:03 +00:00
'desc' => __ ( 'This sets the thousand separator of displayed prices.' , 'woocommerce' ),
'id' => 'woocommerce_price_thousand_sep' ,
'css' => 'width:50px;' ,
'default' => ',' ,
'type' => 'text' ,
2016-08-27 06:14:06 +00:00
'desc_tip' => true ,
2013-07-26 14:36:28 +00:00
),
array (
2016-10-12 10:16:30 +00:00
'title' => __ ( 'Decimal separator' , 'woocommerce' ),
2014-08-31 08:22:03 +00:00
'desc' => __ ( 'This sets the decimal separator of displayed prices.' , 'woocommerce' ),
'id' => 'woocommerce_price_decimal_sep' ,
'css' => 'width:50px;' ,
'default' => '.' ,
'type' => 'text' ,
2016-08-27 06:14:06 +00:00
'desc_tip' => true ,
2013-07-26 14:36:28 +00:00
),
array (
2016-10-12 10:16:30 +00:00
'title' => __ ( 'Number of decimals' , 'woocommerce' ),
2014-08-31 08:22:03 +00:00
'desc' => __ ( 'This sets the number of decimal points shown in displayed prices.' , 'woocommerce' ),
'id' => 'woocommerce_price_num_decimals' ,
'css' => 'width:50px;' ,
'default' => '2' ,
2016-08-27 06:14:06 +00:00
'desc_tip' => true ,
2014-08-31 08:22:03 +00:00
'type' => 'number' ,
2013-08-22 10:58:03 +00:00
'custom_attributes' => array (
2014-08-31 08:22:03 +00:00
'min' => 0 ,
2016-08-27 01:46:45 +00:00
'step' => 1 ,
),
2013-07-26 14:36:28 +00:00
),
2016-08-27 02:08:49 +00:00
array ( 'type' => 'sectionend' , 'id' => 'pricing_options' ),
2013-07-26 14:36:28 +00:00
2014-09-12 11:20:06 +00:00
) );
return apply_filters ( 'woocommerce_get_settings_' . $this -> id , $settings );
2013-07-26 14:36:28 +00:00
}
/**
2016-12-19 11:28:09 +00:00
* Output a color picker input box .
2013-07-26 14:36:28 +00:00
*
* @ param mixed $name
2014-09-07 23:37:55 +00:00
* @ param string $id
2013-07-26 14:36:28 +00:00
* @ param mixed $value
* @ param string $desc ( default : '' )
*/
2014-08-31 08:22:03 +00:00
public function color_picker ( $name , $id , $value , $desc = '' ) {
2015-10-23 15:09:08 +00:00
echo '<div class="color_box">' . wc_help_tip ( $desc ) . '
2016-09-01 20:50:14 +00:00
< 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 >
2014-04-08 22:11:33 +00:00
</ div > ' ;
2013-07-26 14:36:28 +00:00
}
/**
2015-11-03 13:31:20 +00:00
* Save settings .
2013-07-26 14:36:28 +00:00
*/
public function save () {
$settings = $this -> get_settings ();
WC_Admin_Settings :: save_fields ( $settings );
}
}
endif ;
2013-11-19 08:01:46 +00:00
return new WC_Settings_General ();