1
|
|
|
<?php if ( !defined( 'ABSPATH' ) ) exit; |
2
|
|
|
|
3
|
|
|
/* Check if file is include. No direct access possible with file url */ |
4
|
|
|
if ( !defined( 'WPSHOP_VERSION' ) ) { |
5
|
|
|
die( __('Access is not allowed by this way', 'wpshop') ); |
6
|
|
|
} |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Plugin option manager |
10
|
|
|
* |
11
|
|
|
* Define the different method to manage the different options into the plugin |
12
|
|
|
* @author Eoxia <[email protected]> |
13
|
|
|
* @version 1.0 |
14
|
|
|
* @package wpshop |
15
|
|
|
* @subpackage librairies |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Define the different method to manage the different options into the plugin |
20
|
|
|
* @package wpshop |
21
|
|
|
* @subpackage librairies |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
/** Stocke les erreurs de saisies */ |
25
|
|
|
$options_errors = array(); |
26
|
|
|
include(WPSHOP_LIBRAIRIES_DIR . 'options/options_general.class.php'); |
27
|
|
|
include(WPSHOP_LIBRAIRIES_DIR . 'options/options_pages.class.php'); |
28
|
|
|
include(WPSHOP_LIBRAIRIES_DIR . 'options/options_email.class.php'); |
29
|
|
|
include(WPSHOP_LIBRAIRIES_DIR . 'options/options_company.class.php'); |
30
|
|
|
include(WPSHOP_LIBRAIRIES_DIR . 'options/options_payment.class.php'); |
31
|
|
|
include(WPSHOP_LIBRAIRIES_DIR . 'options/options_shipping.class.php'); |
32
|
|
|
include(WPSHOP_LIBRAIRIES_DIR . 'options/options_advanced.class.php'); |
33
|
|
|
include(WPSHOP_LIBRAIRIES_DIR . 'options/options_addons.class.php'); |
34
|
|
|
|
35
|
|
|
class wpshop_options { |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Declare the different groups/subgroups for wpshop options. Execute a filter in order to accept ption from modules/addons |
39
|
|
|
* |
40
|
|
|
* @return array A list with all options groups and subgroup to create. All option fields are defined in each module/addons |
41
|
|
|
*/ |
42
|
|
|
public static function declare_options_groups() { |
43
|
|
|
$groups = array(); |
44
|
|
|
|
45
|
|
|
$groups['wpshop_general_option'] = |
46
|
|
|
array( 'label' => __('General', 'wpshop'), |
47
|
|
|
'subgroups' => array( |
48
|
|
|
'wpshop_general_config' => array('class' => 'wpshop_admin_box_options_general'), |
49
|
|
|
'wpshop_company_info' => array('class' => 'wpshop_admin_box_options_company'), |
50
|
|
|
), |
51
|
|
|
); |
52
|
|
|
$groups['wpshop_catalog_option'] = |
53
|
|
|
array( 'label' => __('Catalog', 'wpshop'), |
54
|
|
|
'subgroups' => array( |
55
|
|
|
'wpshop_catalog_product_option' => array('class' => ' wpshop_admin_box_options_product'), |
56
|
|
|
'wpshop_catalog_main_option' => array('class' => ' wpshop_admin_box_options_catalog'), |
57
|
|
|
'wpshop_catalog_categories_option' => array('class' => ' wpshop_admin_box_options_category'), |
58
|
|
|
), |
59
|
|
|
); |
60
|
|
|
$groups['wpshop_pages_option'] = |
61
|
|
|
array( 'label' => __('Pages', 'wpshop'), |
62
|
|
|
'subgroups' => array( |
63
|
|
|
'wpshop_pages_option' => array('class' => ' wpshop_admin_box_options_pages'), |
64
|
|
|
), |
65
|
|
|
); |
66
|
|
|
$groups['wpshop_display_option'] = |
67
|
|
|
array( 'label' => __('Display', 'wpshop'), |
68
|
|
|
'subgroups' => array( |
69
|
|
|
'wpshop_display_option' => array('class' => ' wpshop_admin_box_options_display'), |
70
|
|
|
'wpshop_customize_display_option' => array('class' => ' wpshop_admin_box_options_display'), |
71
|
|
|
'wpshop_admin_display_option' => array('class' => ' wpshop_admin_box_options_admin_display'), |
72
|
|
|
), |
73
|
|
|
); |
74
|
|
|
$groups['wpshop_emails_option'] = |
75
|
|
|
array( 'label' => __('Emails', 'wpshop'), |
76
|
|
|
'subgroups' => array( |
77
|
|
|
'wpshop_emails' => array('class' => ' wpshop_admin_box_options_email'), |
78
|
|
|
'wpshop_messages' => array('class' => ' wpshop_admin_box_options_message'), |
79
|
|
|
), |
80
|
|
|
); |
81
|
|
|
|
82
|
|
|
$wpshop_shop_type = !empty( $_POST['wpshop_shop_type'] ) ? sanitize_text_field( $_POST['wpshop_shop_type'] ) : ''; |
83
|
|
|
|
84
|
|
|
/** Some options are available only when sale mode is active */ |
85
|
|
|
if((WPSHOP_DEFINED_SHOP_TYPE == 'sale') && !isset($wpshop_shop_type) || (isset($wpshop_shop_type) && ($wpshop_shop_type != 'presentation'))) : |
86
|
|
|
$groups['wpshop_cart_option'] = |
87
|
|
|
array( 'label' => __('Cart', 'wpshop'), |
88
|
|
|
'subgroups' => array( |
89
|
|
|
'wpshop_cart_info' => array('class' => ' wpshop_admin_box_options_cart'), |
90
|
|
|
), |
91
|
|
|
); |
92
|
|
|
$groups['wpshop_payments_option'] = |
93
|
|
|
array( 'label' => __('Payments', 'wpshop'), |
94
|
|
|
'subgroups' => array( |
95
|
|
|
'wpshop_paymentMethod' => array('class' => ' wpshop_admin_box_options_payment_method'), |
96
|
|
|
'wpshop_payment_partial_on_command' => array('class' => ' wpshop_admin_box_options_payment_partial'), |
97
|
|
|
), |
98
|
|
|
); |
99
|
|
|
$groups['wpshop_shipping_option'] = |
100
|
|
|
array( 'label' => __('Shipping', 'wpshop'), |
101
|
|
|
'subgroups' => array( |
102
|
|
|
'wpshop_shipping_rules' => array('class' => ' wpshop_admin_box_options_shipping_rules') |
103
|
|
|
), |
104
|
|
|
); |
105
|
|
|
endif; |
106
|
|
|
|
107
|
|
|
$groups['wpshop_addons_option'] = |
108
|
|
|
array( 'label' => __('Addons', 'wpshop'), |
109
|
|
|
'subgroups' => array( |
110
|
|
|
'wpshop_addons_options' => array('class' => ' wpshop_admin_box_options_addons'), |
111
|
|
|
), |
112
|
|
|
); |
113
|
|
|
|
114
|
|
|
$groups['wpshop_advanced_options'] = |
115
|
|
|
array( 'label' => __('Advanced options', 'wpshop'), |
116
|
|
|
'subgroups' => array( |
117
|
|
|
'wpshop_extra_options' => array('class' => ' wpshop_admin_box_options_advanced'), |
118
|
|
|
), |
119
|
|
|
); |
120
|
|
|
|
121
|
|
|
/** Allows modules and addons to add options to existing list */ |
122
|
|
|
$groups = apply_filters('wpshop_options', $groups); |
123
|
|
|
|
124
|
|
|
return $groups; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Display the main option page. Read all groups/subgroups and options fields defined in wpshop core and modules/addons |
129
|
|
|
*/ |
130
|
|
|
public static function option_main_page() { |
131
|
|
|
global $options_errors; |
132
|
|
|
$tpl_component = array(); |
133
|
|
|
|
134
|
|
|
$options_list = wpshop_options::declare_options_groups(); |
135
|
|
|
ob_start(); |
136
|
|
|
settings_fields('wpshop_options'); |
137
|
|
|
$tpl_component['ADMIN_OPTIONS_FIELDS_FOR_NONCE'] = ob_get_contents(); |
138
|
|
|
ob_end_clean(); |
139
|
|
|
$tpl_component['ADMIN_OPTIONS_TAB_LIST'] = ''; |
140
|
|
|
$tpl_component['ADMIN_OPTIONS_TAB_CONTENT_LIST'] = ''; |
141
|
|
|
if ( !empty($options_list) ) { |
142
|
|
|
foreach ( $options_list as $group_key => $group_content) { |
143
|
|
|
$sub_tpl_component = array(); |
144
|
|
|
if ( !empty($group_content['subgroups']) && is_array($group_content['subgroups']) ) { |
145
|
|
|
$sub_tpl_component['ADMIN_OPTIONS_GROUP_CONTENT'] = ''; |
146
|
|
|
$sub_tpl_component['ADMIN_OPTIONS_TAB_KEY'] = $group_key; |
147
|
|
|
$sub_tpl_component['ADMIN_OPTIONS_TAB_LABEL'] = ( !empty($group_content['label']) ) ? $group_content['label'] : ''; |
148
|
|
|
$tpl_component['ADMIN_OPTIONS_TAB_LIST'] .= wpshop_display::display_template_element('wpshop_admin_options_group_tab', $sub_tpl_component, array(), 'admin'); |
149
|
|
|
foreach ( $group_content['subgroups'] as $subgroup_key => $subgroup_def) { |
150
|
|
|
ob_start(); |
151
|
|
|
do_settings_sections( $subgroup_key ); |
152
|
|
|
$sub_tpl_component['ADMIN_OPTIONS_SUBGROUP_CONTENT'] = ob_get_contents(); |
153
|
|
|
ob_end_clean(); |
154
|
|
|
$sub_tpl_component['ADMIN_OPTIONS_SUBGROUP_CLASS'] = $subgroup_def['class']; |
155
|
|
|
$sub_tpl_component['ADMIN_OPTIONS_GROUP_CONTENT'] .= wpshop_display::display_template_element('wpshop_admin_options_subgroup_container', $sub_tpl_component, array(), 'admin'); |
156
|
|
|
} |
157
|
|
|
$tpl_component['ADMIN_OPTIONS_TAB_CONTENT_LIST'] .= wpshop_display::display_template_element('wpshop_admin_options_group_container', $sub_tpl_component, array(), 'admin'); |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
echo wpshop_display::display_template_element('wpshop_admin_options_main_page', $tpl_component, array(), 'admin'); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* Declare the different options for the plugin |
168
|
|
|
*/ |
169
|
|
|
public static function add_options(){ |
170
|
|
|
global $wpshop_display_option; |
171
|
|
|
|
172
|
|
|
|
173
|
|
|
/*Catalog - Main */ |
174
|
|
|
register_setting('wpshop_options', 'wpshop_catalog_main_option', array('wpshop_options', 'wpshop_options_validate_catalog_main_option')); |
175
|
|
|
add_settings_section('wpshop_catalog_main_section', '<span class="dashicons dashicons-category"></span>'.__('Catalog', 'wpshop'), array('wpshop_options', 'plugin_section_text'), 'wpshop_catalog_main_option'); |
176
|
|
|
add_settings_field('wpshop_catalog_empty_price_behaviour', __('Empty price', 'wpshop'), array('wpshop_options', 'wpshop_catalog_empty_price_behaviour'), 'wpshop_catalog_main_option', 'wpshop_catalog_main_section'); |
177
|
|
|
/* Catalog - Product */ |
178
|
|
|
register_setting('wpshop_options', 'wpshop_catalog_product_option', array('wpshop_options', 'wpshop_options_validate_catalog_product_option')); |
179
|
|
|
add_settings_section('wpshop_catalog_product_section', '<span class="dashicons dashicons-archive"></span>'.__('Products', 'wpshop'), array('wpshop_options', 'plugin_section_text'), 'wpshop_catalog_product_option'); |
180
|
|
|
add_settings_field('wpshop_catalog_product_slug', __('Products common rewrite param', 'wpshop'), array('wpshop_options', 'wpshop_catalog_product_slug_field'), 'wpshop_catalog_product_option', 'wpshop_catalog_product_section'); |
181
|
|
|
/* Catalog - Categories */ |
182
|
|
|
register_setting('wpshop_options', 'wpshop_catalog_categories_option', array('wpshop_options', 'wpshop_options_validate_catalog_categories_option')); |
183
|
|
|
add_settings_section('wpshop_catalog_categories_section', '<span class="dashicons dashicons-portfolio"></span>'.__('Categories', 'wpshop'), array('wpshop_options', 'plugin_section_text'), 'wpshop_catalog_categories_option'); |
184
|
|
|
add_settings_field('wpshop_catalog_categories_slug', __('Categories common rewrite param', 'wpshop'), array('wpshop_options', 'wpshop_catalog_categories_slug_field'), 'wpshop_catalog_categories_option', 'wpshop_catalog_categories_section'); |
185
|
|
|
add_settings_field('wpshop_catalog_no_category_slug', __('Default category slug for unassociated product', 'wpshop'), array('wpshop_options', 'wpshop_catalog_no_category_slug_field'), 'wpshop_catalog_categories_option', 'wpshop_catalog_categories_section'); |
186
|
|
|
|
187
|
|
|
/* General option */ |
188
|
|
|
wpshop_general_options::declare_options(); |
189
|
|
|
|
190
|
|
|
/* Company */ |
191
|
|
|
wpshop_company_options::declare_options(); |
192
|
|
|
|
193
|
|
|
/* Payments */ |
194
|
|
|
$wpshop_shop_type = !empty( $_POST['wpshop_shop_type'] ) ? sanitize_text_field( $_POST['wpshop_shop_type'] ) : ''; |
195
|
|
|
$old_wpshop_shop_type = !empty( $_POST['old_wpshop_shop_type'] ) ? sanitize_text_field( $_POST['old_wpshop_shop_type'] ) : ''; |
196
|
|
View Code Duplication |
if((WPSHOP_DEFINED_SHOP_TYPE == 'sale') && !isset($wpshop_shop_type) || (isset($wpshop_shop_type) && ($wpshop_shop_type != 'presentation')) && !isset($old_wpshop_shop_type) || (isset($old_wpshop_shop_type) && ($old_wpshop_shop_type != 'presentation'))){ |
|
|
|
|
197
|
|
|
wpshop_payment_options::declare_options(); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/* Cart */ |
201
|
|
|
if((WPSHOP_DEFINED_SHOP_TYPE == 'sale') && !isset($wpshop_shop_type) || (isset($wpshop_shop_type) && ($wpshop_shop_type != 'presentation')) && !isset($old_wpshop_shop_type) || (isset($old_wpshop_shop_type) && ($old_wpshop_shop_type != 'presentation'))){ |
202
|
|
|
register_setting('wpshop_options', 'wpshop_cart_option', array('wpshop_options', 'wpshop_options_validate_cart')); |
203
|
|
|
add_settings_section('wpshop_cart_info', '<span class="dashicons dashicons-cart"></span>'.__('Cart', 'wpshop'), array('wpshop_options', 'plugin_section_text'), 'wpshop_cart_info'); |
204
|
|
|
add_settings_field('wpshop_cart_product_added_behaviour', __('Action when produt is added succesfully into cart', 'wpshop'), array('wpshop_options', 'wpshop_cart_product_added_behaviour_field'), 'wpshop_cart_info', 'wpshop_cart_info'); |
205
|
|
|
add_settings_field('wpshop_cart_product_added_to_quotation_behaviour', __('Action when produt is added succesfully into a quotation', 'wpshop'), array('wpshop_options', 'wpshop_cart_product_added_to_quotation_behaviour_field'), 'wpshop_cart_info', 'wpshop_cart_info'); |
206
|
|
|
add_settings_field('wpshop_cart_total_item_nb', __('Only a limited number of products in cart', 'wpshop'), array('wpshop_options', 'wpshop_cart_total_item_nb_field'), 'wpshop_cart_info', 'wpshop_cart_info'); |
207
|
|
|
//add_settings_field('wpshop_cart_same_item_nb', __('Number of same item allowed into cart', 'wpshop'), array('wpshop_options', 'wpshop_cart_same_item_nb_field'), 'wpshop_cart_info', 'wpshop_cart_info'); |
|
|
|
|
208
|
|
|
register_setting('wpshop_options', 'wpshop_catalog_product_option', array('wpshop_options', 'wpshop_catalog_product_variation_option_validate')); |
209
|
|
|
add_settings_field('wpshop_catalog_product_option', __('Variation product display options for all products', 'wpshop'), array('wpshop_options', 'wpshop_catalog_varition_product_field'), 'wpshop_catalog_product_option', 'wpshop_catalog_product_section'); |
210
|
|
|
do_action('wsphop_options'); |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
do_action('wsphop_options'); |
214
|
|
|
|
215
|
|
|
/* Pages */ |
216
|
|
|
wpshop_page_options::declare_options(); |
217
|
|
|
|
218
|
|
|
/* Emails */ |
219
|
|
|
wpshop_email_options::declare_options(); |
220
|
|
|
|
221
|
|
|
/* Addons */ |
222
|
|
|
$wpshop_addons_settings = new wpshop_addons_settings(); |
223
|
|
|
$wpshop_addons_settings->declare_options(); |
224
|
|
|
|
225
|
|
|
/* Advanced Settings */ |
226
|
|
|
$wpshop_advanced_settings = new wpshop_advanced_settings(); |
227
|
|
|
$wpshop_advanced_settings->declare_options(); |
228
|
|
|
|
229
|
|
|
/* Shipping section */ |
230
|
|
View Code Duplication |
if((WPSHOP_DEFINED_SHOP_TYPE == 'sale') && !isset($wpshop_shop_type) || (isset($wpshop_shop_type) && ($wpshop_shop_type != 'presentation')) && !isset($old_wpshop_shop_type) || (isset($old_wpshop_shop_type) && ($old_wpshop_shop_type != 'presentation'))){ |
|
|
|
|
231
|
|
|
$wpshop_shipping_options = new wpshop_shipping_options(); |
232
|
|
|
$wpshop_shipping_options->declare_options(); |
233
|
|
|
} |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
// Common section description |
237
|
|
|
public static function plugin_section_text() { |
238
|
|
|
echo ''; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/* ------------------------------ */ |
242
|
|
|
/* --------- CATALOG INFO ------- */ |
243
|
|
|
/* ------------------------------ */ |
244
|
|
|
public static function wpshop_catalog_empty_price_behaviour() { |
245
|
|
|
$options = get_option('wpshop_catalog_main_option'); |
246
|
|
|
echo '<input type="checkbox"' . (!empty($options['wpshop_catalog_empty_price_behaviour']) ? ' checked="checked" ' : '') . ' value="yes" name="wpshop_catalog_main_option[wpshop_catalog_empty_price_behaviour]" id="wpshop_catalog_empty_price_behaviour" /> <label for="wpshop_catalog_empty_price_behaviour" >' . __('Hide price and add to cart button when price is empty or equal to 0', 'wpshop') . '</label>'; |
247
|
|
|
} |
248
|
|
|
public static function wpshop_catalog_product_slug_field(){ |
249
|
|
|
$options = get_option('wpshop_catalog_product_option'); |
250
|
|
|
$catalog_cat_options = get_option('wpshop_catalog_categories_option'); |
251
|
|
|
echo '<input type="checkbox"' . (!empty($options['wpshop_catalog_product_slug_with_category']) ? ' checked="checked" ' : '') . ' value="yes" name="wpshop_catalog_product_option[wpshop_catalog_product_slug_with_category]" id="wpshop_catalog_product_slug_with_category" /> <label for="wpshop_catalog_product_slug_with_category">' . __('Use product category in url', 'wpshop') . '</label><br/> |
252
|
|
|
<div class="alignleft" >' . site_url('/') . '</div> |
253
|
|
|
<div class="alignleft wpshop_options_catalog_product_rewrite" ><input type="text" name="wpshop_catalog_product_option[wpshop_catalog_product_slug]" value="' . (!empty($options['wpshop_catalog_product_slug']) ? $options['wpshop_catalog_product_slug'] : WPSHOP_CATALOG_PRODUCT_SLUG) . '" /></div> |
254
|
|
|
<div class="alignleft wpshop_options_catalog_product_rewrite" ><span class="wpshop_catalog_product_slug_category' . (empty($options['wpshop_catalog_product_slug_with_category']) ? ' disable' : '') . '" >/' . (!empty($catalog_cat_options['wpshop_catalog_categories_slug']) ? $catalog_cat_options['wpshop_catalog_categories_slug'] : WPSHOP_CATALOG_CATEGORIES_SLUG) . '</span></div> |
255
|
|
|
<div class="alignleft wpshop_options_catalog_product_rewrite" >/' . __('Your_product_slug', 'wpshop') . '</div> |
256
|
|
|
<div class="alignleft" ><a href="#" title="'.__('This slug will be used in url to describe products page','wpshop').'" class="wpshop_infobulle_marker">?</a></div><br /><br /> |
257
|
|
|
<div><span style="color: red;" class="dashicons dashicons-megaphone"></span> '.__('"/" permit to disable slug of products (<b>but don\'t work with rewrites plugins</b>)','wpshop').'</div>'; |
258
|
|
|
} |
259
|
|
|
public static function wpshop_catalog_categories_slug_field(){ |
260
|
|
|
$options = get_option('wpshop_catalog_categories_option'); |
261
|
|
|
echo '<input type="text" name="wpshop_catalog_categories_option[wpshop_catalog_categories_slug]" value="' . (!empty($options['wpshop_catalog_categories_slug']) ? $options['wpshop_catalog_categories_slug'] : WPSHOP_CATALOG_CATEGORIES_SLUG) . '" /> |
262
|
|
|
<a href="#" title="'.__('This slug will be used in url to describe catagories page','wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
263
|
|
|
} |
264
|
|
|
public static function wpshop_catalog_no_category_slug_field(){ |
265
|
|
|
$options = get_option('wpshop_catalog_categories_option'); |
266
|
|
|
echo '<input type="text" name="wpshop_catalog_categories_option[wpshop_catalog_no_category_slug]" value="' . (!empty($options['wpshop_catalog_no_category_slug']) ? $options['wpshop_catalog_no_category_slug'] : WPSHOP_CATALOG_PRODUCT_NO_CATEGORY) . '" /> |
267
|
|
|
<a href="#" title="'.__('This slug will be used for products not being related to any category ','wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
/* Processing */ |
271
|
|
|
public static function wpshop_options_validate_catalog_product_option($input){ |
272
|
|
|
foreach($input as $option_key => $option_value){ |
273
|
|
|
switch($option_key){ |
274
|
|
|
default: |
|
|
|
|
275
|
|
|
$new_input[$option_key] = $option_value; |
276
|
|
|
break; |
277
|
|
|
} |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
return $new_input; |
|
|
|
|
281
|
|
|
} |
282
|
|
|
public static function wpshop_options_validate_catalog_categories_option($input){ |
283
|
|
|
foreach($input as $option_key => $option_value){ |
284
|
|
|
switch($option_key){ |
285
|
|
|
default: |
|
|
|
|
286
|
|
|
$new_input[$option_key] = $option_value; |
287
|
|
|
break; |
288
|
|
|
} |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
return $new_input; |
|
|
|
|
292
|
|
|
} |
293
|
|
|
public static function wpshop_options_validate_catalog_main_option($input){ |
294
|
|
|
$new_input = $input; |
295
|
|
|
if ( !empty($input) && is_array( $input ) ) { |
296
|
|
|
foreach($input as $option_key => $option_value){ |
297
|
|
|
switch($option_key){ |
298
|
|
|
default: |
|
|
|
|
299
|
|
|
$new_input[$option_key] = $option_value; |
300
|
|
|
break; |
301
|
|
|
} |
302
|
|
|
} |
303
|
|
|
} |
304
|
|
|
flush_rewrite_rules(); |
305
|
|
|
return $new_input; |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
public static function wpshop_catalog_varition_product_field () { |
309
|
|
|
$catalog_product_option = get_option('wpshop_catalog_product_option'); |
310
|
|
|
$output = '<input type="checkbox" name="wpshop_catalog_product_option[price_display][text_from]" id="wpshop_catalog_product_option_price_display_text_from" ' .( ( !empty($catalog_product_option) && !empty($catalog_product_option['price_display']) && !empty($catalog_product_option['price_display']['text_from']) ) ? 'checked="checked"' : '' ). ' /> '; |
311
|
|
|
$output .= '<label for="wpshop_catalog_product_option_price_display_text_from">'. __('Display "price from" before basic price of product', 'wpshop').'</label><br/>'; |
312
|
|
|
$output .= '<input type="checkbox" name="wpshop_catalog_product_option[price_display][lower_price]" id="wpshop_catalog_product_option_price_display_lower_price" ' .( ( !empty($catalog_product_option) && !empty($catalog_product_option['price_display']) && !empty($catalog_product_option['price_display']['lower_price']) ) ? 'checked="checked"' : '' ). ' /> '; |
313
|
|
|
$output .= '<label for="wpshop_catalog_product_option_price_display_lower_price">'. __('Display the lowest price of variation', 'wpshop').'</label>'; |
314
|
|
|
echo $output; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
public static function wpshop_catalog_product_variation_option_validate ($input) { |
318
|
|
|
return $input; |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
/* ------------------------- */ |
322
|
|
|
/* --------- CART ------- */ |
323
|
|
|
/* ------------------------- */ |
324
|
|
|
public static function wpshop_cart_total_item_nb_field() { |
325
|
|
|
$cart_option = get_option('wpshop_cart_option', array()); |
|
|
|
|
326
|
|
|
$output = ''; |
327
|
|
|
|
328
|
|
|
$input_def = array(); |
329
|
|
|
$input_def['name'] = ''; |
330
|
|
|
$input_def['id'] = 'wpshop_cart_option_total_nb_of_item_allowed'; |
331
|
|
|
$input_def['type'] = 'text'; |
332
|
|
|
$input_def['value'] = !empty($cart_option['total_nb_of_item_allowed']) ? $cart_option['total_nb_of_item_allowed'][0] : ''; |
333
|
|
|
$output .= wpshop_form::check_input_type($input_def, 'wpshop_cart_option[total_nb_of_item_allowed]') . '<a href="#" title="'.__('This value count all quantities in cart. Example : 2 products A + 3 products B = 5 products','wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
334
|
|
|
|
335
|
|
|
echo $output; |
336
|
|
|
} |
337
|
|
|
function wpshop_cart_same_item_nb_field() { |
|
|
|
|
338
|
|
|
$cart_option = get_option('wpshop_cart_option', 0); |
339
|
|
|
$output = ''; |
340
|
|
|
|
341
|
|
|
$input_def = array(); |
342
|
|
|
$input_def['name'] = ''; |
343
|
|
|
$input_def['id'] = 'wpshop_cart_option_nb_of_same_item_allowed'; |
344
|
|
|
$input_def['type'] = 'text'; |
345
|
|
|
$input_def['value'] = $cart_option['total_nb_of_same_item_allowed'][0]; |
346
|
|
|
$output .= wpshop_form::check_input_type($input_def, 'wpshop_cart_option[total_nb_of_same_item_allowed]') . '<a href="#" title="'.__('Empty for no restriction','wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
347
|
|
|
|
348
|
|
|
echo $output; |
349
|
|
|
} |
350
|
|
|
public static function wpshop_cart_product_added_behaviour_field() { |
351
|
|
|
$cart_option = get_option('wpshop_cart_option', array('dialog_msg')); |
|
|
|
|
352
|
|
|
$output = ''; |
353
|
|
|
|
354
|
|
|
$input_def = array(); |
355
|
|
|
$input_def['name'] = ''; |
356
|
|
|
$input_def['id'] = 'wpshop_cart_option_action_after_product_added_to_cart'; |
357
|
|
|
$input_def['type'] = 'radio'; |
358
|
|
|
$input_def['valueToPut'] = 'index'; |
359
|
|
|
$input_def['value'] = $cart_option['product_added_to_cart']; |
360
|
|
|
$input_def['possible_value'] = array('dialog_msg' => __('Display the dialog allowing to choose between continue shopping or go to cart', 'wpshop'), 'cart_page' => __('Automaticaly send user to cart page', 'wpshop')); |
361
|
|
|
$input_def['options_label']['original'] = true; |
362
|
|
|
$input_def['options_label']['container'] = true; |
363
|
|
|
$output .= wpshop_form::check_input_type($input_def, 'wpshop_cart_option[product_added_to_cart]'); |
364
|
|
|
|
365
|
|
|
$hide = ( (!empty($cart_option) && !empty($cart_option['product_added_to_cart'][0]) && $cart_option['product_added_to_cart'][0] == 'cart_page') ? 'wpshopHide' : null); |
366
|
|
|
$output .= '<div id="wpshop_cart_option_animation_cart_type" class="' .$hide. '"><label for="wpshop_cart_option[animation_cart_type]">' .__('Cart animation type', 'wpshop'). '</label>'; |
367
|
|
|
$output .= '<select name="wpshop_cart_option[animation_cart_type]" id="wpshop_cart_option[animation_cart_type]">'; |
368
|
|
|
$output .= '<option value="pop-in" ' .( ( !empty($cart_option['animation_cart_type']) && $cart_option['animation_cart_type'] == 'pop-in') ? 'selected="selected"' : null). '>' .__('Dialog box', 'wpshop'). '</option>'; |
369
|
|
|
$output .= '<option value="animation" ' .( ( !empty($cart_option['animation_cart_type']) && $cart_option['animation_cart_type'] == 'animation') ? 'selected="selected"' : null). '>' .__('Image animation', 'wpshop'). '</option>'; |
370
|
|
|
$output .= '</select></div>'; |
371
|
|
|
|
372
|
|
|
echo $output; |
373
|
|
|
|
374
|
|
|
|
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
|
378
|
|
|
public static function wpshop_cart_product_added_to_quotation_behaviour_field() { |
379
|
|
|
$cart_option = get_option('wpshop_cart_option', array('dialog_msg')); |
|
|
|
|
380
|
|
|
$output = ''; |
381
|
|
|
|
382
|
|
|
$input_def = array(); |
383
|
|
|
$input_def['name'] = ''; |
384
|
|
|
$input_def['id'] = 'wpshop_cart_option_action_after_product_added_to_quotation'; |
385
|
|
|
$input_def['type'] = 'radio'; |
386
|
|
|
$input_def['valueToPut'] = 'index'; |
387
|
|
|
$input_def['value'] = ( !empty($cart_option['product_added_to_quotation']) ? $cart_option['product_added_to_quotation'] : null ); |
388
|
|
|
$input_def['possible_value'] = array('dialog_msg' => __('Display the dialog allowing to choose between continue shopping or go to cart', 'wpshop'), 'cart_page' => __('Automaticaly send user to cart page', 'wpshop')); |
389
|
|
|
$input_def['options_label']['original'] = true; |
390
|
|
|
$input_def['options_label']['container'] = true; |
391
|
|
|
$output .= wpshop_form::check_input_type($input_def, 'wpshop_cart_option[product_added_to_quotation]'); |
392
|
|
|
|
393
|
|
|
echo $output; |
394
|
|
|
} |
395
|
|
|
public static function wpshop_options_validate_cart( $input ) { |
396
|
|
|
|
397
|
|
View Code Duplication |
if ( empty( $input ) || empty( $input[ 'display_newsletter' ] ) || empty( $input[ 'display_newsletter' ][ 'partner_subscription' ] ) ) { |
|
|
|
|
398
|
|
|
$input[ 'display_newsletter' ][ 'partner_subscription' ] = 'no'; |
399
|
|
|
} |
400
|
|
|
|
401
|
|
View Code Duplication |
if ( empty( $input ) || empty( $input[ 'display_newsletter' ] ) || empty( $input[ 'display_newsletter' ][ 'site_subscription' ] ) ) { |
|
|
|
|
402
|
|
|
$input[ 'display_newsletter' ][ 'site_subscription' ] = 'no'; |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
return $input; |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
|
409
|
|
|
} |
410
|
|
|
|
411
|
|
|
?> |
|
|
|
|
412
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.