| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Side Cart Options. |
| 5 |
* |
| 6 |
* @package Merchant |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; // Exit if accessed directly |
| 11 |
} |
| 12 |
|
| 13 |
Merchant_Admin_Options::create( array( |
| 14 |
'module' => Merchant_Side_Cart::MODULE_ID, |
| 15 |
'title' => esc_html__( 'Display Settings', 'merchant' ), |
| 16 |
'fields' => array( |
| 17 |
array( |
| 18 |
'id' => 'show_after_add_to_cart', |
| 19 |
'type' => 'switcher', |
| 20 |
'title' => __( 'Shop Page', 'merchant' ), |
| 21 |
'desc' => __( 'Show side cart after adding product to the cart from shop archive page', 'merchant' ), |
| 22 |
'default' => 1, |
| 23 |
), |
| 24 |
array( |
| 25 |
'id' => 'show_after_add_to_cart_single_product', |
| 26 |
'type' => 'switcher', |
| 27 |
'title' => __( 'Product Page', 'merchant' ), |
| 28 |
'desc' => __( 'Display side cart after adding product to the cart from product single page', 'merchant' ), |
| 29 |
'default' => 0, |
| 30 |
), |
| 31 |
array( |
| 32 |
'id' => 'show_on_cart_url_click', |
| 33 |
'type' => 'switcher', |
| 34 |
'title' => __( 'Cart Icons', 'merchant' ), |
| 35 |
'desc' => __( 'Show side cart when a user clicks on the cart URL or menu items', 'merchant' ), |
| 36 |
'default' => 1, |
| 37 |
), |
| 38 |
), |
| 39 |
) ); |
| 40 |
|
| 41 |
Merchant_Admin_Options::create( array( |
| 42 |
'module' => Merchant_Side_Cart::MODULE_ID, |
| 43 |
'title' => esc_html__( 'Upsell', 'merchant' ), |
| 44 |
'fields' => array( |
| 45 |
array( |
| 46 |
'id' => 'use_upsells', |
| 47 |
'type' => 'switcher', |
| 48 |
'title' => __( 'Cart Upsells', 'merchant' ), |
| 49 |
'desc' => __( 'Enable upsell products in the side cart', 'merchant' ), |
| 50 |
'default' => 0, |
| 51 |
), |
| 52 |
array( |
| 53 |
'id' => 'upsells_type', |
| 54 |
'type' => 'select', |
| 55 |
//'title' => esc_html__( 'Placement', 'merchant' ), |
| 56 |
'options' => array( |
| 57 |
'related_products' => esc_html__( 'Related Products', 'merchant' ), |
| 58 |
'custom_upsell' => esc_html__( 'Custom Upsell', 'merchant' ), |
| 59 |
), |
| 60 |
'default' => 'related_products', |
| 61 |
'conditions' => array( |
| 62 |
'relation' => 'AND', // AND/OR, If not provided, only first term will be considered |
| 63 |
'terms' => array( |
| 64 |
array( |
| 65 |
'field' => 'use_upsells', // field ID |
| 66 |
'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains |
| 67 |
'value' => true, // can be a single value or an array of string/number/int |
| 68 |
), |
| 69 |
), |
| 70 |
), |
| 71 |
), |
| 72 |
|
| 73 |
array( |
| 74 |
'id' => 'custom_upsells', |
| 75 |
'type' => 'flexible_content', |
| 76 |
'sorting' => true, |
| 77 |
'accordion' => true, |
| 78 |
'duplicate' => false, |
| 79 |
'style' => Merchant_Side_Cart::MODULE_ID . '-style default', |
| 80 |
'button_label' => esc_html__( 'Add New Upsell', 'merchant' ), |
| 81 |
'conditions' => array( |
| 82 |
'relation' => 'AND', // AND/OR, If not provided, only first term will be considered |
| 83 |
'terms' => array( |
| 84 |
array( |
| 85 |
'field' => 'use_upsells', // field ID |
| 86 |
'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains |
| 87 |
'value' => true, // can be a single value or an array of string/number/int |
| 88 |
), |
| 89 |
array( |
| 90 |
'field' => 'upsells_type', // field ID |
| 91 |
'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains |
| 92 |
'value' => 'custom_upsell', // can be a single value or an array of string/number/int |
| 93 |
), |
| 94 |
), |
| 95 |
), |
| 96 |
'default' => array( |
| 97 |
array( |
| 98 |
'layout' => 'upsell-details', |
| 99 |
'upsell_based_on' => 'products', |
| 100 |
'exclude_product_ids' => 0, |
| 101 |
'custom_upsell_type' => 'products', |
| 102 |
), |
| 103 |
), |
| 104 |
'layouts' => array( |
| 105 |
'upsell-details' => array( |
| 106 |
'title' => esc_html__( 'Custom Upsell', 'merchant' ), |
| 107 |
'title-field' => 'offer-title', // text field ID to use as title for the layout |
| 108 |
'fields' => array( |
| 109 |
array( |
| 110 |
'id' => 'upsell_based_on', |
| 111 |
'type' => 'select', |
| 112 |
'title' => esc_html__( 'Trigger to add the upsell for', 'merchant' ), |
| 113 |
'options' => array( |
| 114 |
'all' => esc_html__( 'All products', 'merchant' ), |
| 115 |
'products' => esc_html__( 'Specific product', 'merchant' ), |
| 116 |
'categories' => esc_html__( 'Specific category', 'merchant' ), |
| 117 |
), |
| 118 |
'default' => 'products', |
| 119 |
), |
| 120 |
array( |
| 121 |
'id' => 'product_ids', |
| 122 |
'type' => 'products_selector', |
| 123 |
'title' => esc_html__( 'Select product(s)', 'merchant' ), |
| 124 |
'multiple' => true, |
| 125 |
'desc' => esc_html__( 'Select the product(s) that you want to add the upsell for', 'merchant' ), |
| 126 |
'allowed_types' => array( 'simple', 'variable' ), |
| 127 |
'conditions' => array( |
| 128 |
'relation' => 'AND', // AND/OR, If not provided, only first term will be considered |
| 129 |
'terms' => array( |
| 130 |
array( |
| 131 |
'field' => 'upsell_based_on', // field ID |
| 132 |
'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains |
| 133 |
'value' => 'products', // can be a single value or an array of string/number/int |
| 134 |
), |
| 135 |
), |
| 136 |
), |
| 137 |
), |
| 138 |
array( |
| 139 |
'id' => 'category_slugs', |
| 140 |
'type' => 'select_ajax', |
| 141 |
'title' => esc_html__( 'Select category(es)', 'merchant' ), |
| 142 |
'source' => 'options', |
| 143 |
'multiple' => true, |
| 144 |
'options' => Merchant_Admin_Options::get_category_select2_choices(), |
| 145 |
'placeholder' => esc_html__( 'Search category(es)', 'merchant' ), |
| 146 |
'desc' => esc_html__( 'Select the category(es) that you want to add the upsell for.', 'merchant' ), |
| 147 |
'conditions' => array( |
| 148 |
'relation' => 'AND', // AND/OR, If not provided, only first term will be considered |
| 149 |
'terms' => array( |
| 150 |
array( |
| 151 |
'field' => 'upsell_based_on', // field ID |
| 152 |
'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains |
| 153 |
'value' => 'categories', // can be a single value or an array of string/number/int |
| 154 |
), |
| 155 |
), |
| 156 |
), |
| 157 |
), |
| 158 |
array( |
| 159 |
'id' => 'exclude_product_ids_toggle', |
| 160 |
'type' => 'switcher', |
| 161 |
'title' => __( 'Exclusion List', 'merchant' ), |
| 162 |
'desc' => __( 'Select products that will not display upsells.', 'merchant' ), |
| 163 |
'default' => 0, |
| 164 |
'conditions' => array( |
| 165 |
'relation' => 'AND', // AND/OR, If not provided, only first term will be considered |
| 166 |
'terms' => array( |
| 167 |
array( |
| 168 |
'field' => 'upsell_based_on', // field ID |
| 169 |
'operator' => 'in', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains |
| 170 |
'value' => array( 'all', 'categories' ), // can be a single value or an array of string/number/int |
| 171 |
), |
| 172 |
), |
| 173 |
), |
| 174 |
), |
| 175 |
array( |
| 176 |
'id' => 'excluded_product_ids', |
| 177 |
'type' => 'products_selector', |
| 178 |
'title' => esc_html__( 'Trigger', 'merchant' ), |
| 179 |
'multiple' => true, |
| 180 |
'desc' => esc_html__( 'Upsell will not be displayed for selected products.', 'merchant' ), |
| 181 |
'allowed_types' => array( 'simple', 'variable' ), |
| 182 |
'conditions' => array( |
| 183 |
'relation' => 'AND', // AND/OR, If not provided, only first term will be considered |
| 184 |
'terms' => array( |
| 185 |
array( |
| 186 |
'field' => 'upsell_based_on', // field ID |
| 187 |
'operator' => 'in', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains |
| 188 |
'value' => array( 'all', 'categories' ), // can be a single value or an array of string/number/int |
| 189 |
), |
| 190 |
array( |
| 191 |
'field' => 'exclude_product_ids_toggle', // field ID |
| 192 |
'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains |
| 193 |
'value' => true, // can be a single value or an array of string/number/int |
| 194 |
), |
| 195 |
), |
| 196 |
), |
| 197 |
), |
| 198 |
array( |
| 199 |
'id' => 'custom_upsell_type', |
| 200 |
'type' => 'select', |
| 201 |
'title' => esc_html__( 'Trigger upsells', 'merchant' ), |
| 202 |
'options' => array( |
| 203 |
'products' => esc_html__( 'Specific product', 'merchant' ), |
| 204 |
'categories' => esc_html__( 'Specific category', 'merchant' ), |
| 205 |
), |
| 206 |
'default' => 'products', |
| 207 |
), |
| 208 |
array( |
| 209 |
'id' => 'upsells_product_ids', |
| 210 |
'type' => 'products_selector', |
| 211 |
'title' => esc_html__( 'Select product(s)', 'merchant' ), |
| 212 |
'multiple' => true, |
| 213 |
'desc' => esc_html__( 'Select the product(s) that you want to add the upsell for', 'merchant' ), |
| 214 |
'allowed_types' => array( 'simple', 'variable' ), |
| 215 |
'conditions' => array( |
| 216 |
'relation' => 'AND', // AND/OR, If not provided, only first term will be considered |
| 217 |
'terms' => array( |
| 218 |
array( |
| 219 |
'field' => 'custom_upsell_type', // field ID |
| 220 |
'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains |
| 221 |
'value' => 'products', // can be a single value or an array of string/number/int |
| 222 |
), |
| 223 |
), |
| 224 |
), |
| 225 |
), |
| 226 |
array( |
| 227 |
'id' => 'upsells_category_slugs', |
| 228 |
'type' => 'select_ajax', |
| 229 |
'title' => esc_html__( 'Select category(es)', 'merchant' ), |
| 230 |
'source' => 'options', |
| 231 |
'multiple' => true, |
| 232 |
'options' => Merchant_Admin_Options::get_category_select2_choices(), |
| 233 |
'placeholder' => esc_html__( 'Search category(es)', 'merchant' ), |
| 234 |
'desc' => esc_html__( 'Select the category(es) that you want to display the upsell products form.', 'merchant' ), |
| 235 |
'conditions' => array( |
| 236 |
'relation' => 'AND', // AND/OR, If not provided, only first term will be considered |
| 237 |
'terms' => array( |
| 238 |
array( |
| 239 |
'field' => 'custom_upsell_type', // field ID |
| 240 |
'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains |
| 241 |
'value' => 'categories', // can be a single value or an array of string/number/int |
| 242 |
), |
| 243 |
), |
| 244 |
), |
| 245 |
), |
| 246 |
), |
| 247 |
), |
| 248 |
), |
| 249 |
), |
| 250 |
|
| 251 |
|
| 252 |
array( |
| 253 |
'id' => 'upsells_products_count_limitation_toggle', |
| 254 |
'label' => __( 'Limit the number of upsells in the cart', 'merchant' ), |
| 255 |
'type' => 'checkbox', |
| 256 |
'default' => 0, |
| 257 |
'conditions' => array( |
| 258 |
'relation' => 'AND', // AND/OR, If not provided, only first term will be considered |
| 259 |
'terms' => array( |
| 260 |
array( |
| 261 |
'field' => 'use_upsells', // field ID |
| 262 |
'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains |
| 263 |
'value' => true, // can be a single value or an array of string/number/int |
| 264 |
), |
| 265 |
), |
| 266 |
), |
| 267 |
), |
| 268 |
array( |
| 269 |
'id' => 'upsells_products_count_limitation', |
| 270 |
'title' => __( 'Maximum number of upsells to display', 'merchant' ), |
| 271 |
'type' => 'number', |
| 272 |
'default' => 10, |
| 273 |
'min' => 1, |
| 274 |
'step' => 1, |
| 275 |
'conditions' => array( |
| 276 |
'relation' => 'AND', // AND/OR, If not provided, only first term will be considered |
| 277 |
'terms' => array( |
| 278 |
array( |
| 279 |
'field' => 'use_upsells', // field ID |
| 280 |
'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains |
| 281 |
'value' => true, // can be a single value or an array of string/number/int |
| 282 |
), |
| 283 |
array( |
| 284 |
'field' => 'upsells_products_count_limitation_toggle', // field ID |
| 285 |
'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains |
| 286 |
'value' => true, // can be a single value or an array of string/number/int |
| 287 |
), |
| 288 |
), |
| 289 |
), |
| 290 |
), |
| 291 |
array( |
| 292 |
'id' => 'upsells_title', |
| 293 |
'title' => __( 'Upsell title', 'merchant' ), |
| 294 |
'type' => 'text', |
| 295 |
'default' => __( 'You might also like', 'merchant' ), |
| 296 |
'conditions' => array( |
| 297 |
'relation' => 'AND', // AND/OR, If not provided, only first term will be considered |
| 298 |
'terms' => array( |
| 299 |
array( |
| 300 |
'field' => 'use_upsells', // field ID |
| 301 |
'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains |
| 302 |
'value' => true, // can be a single value or an array of string/number/int |
| 303 |
), |
| 304 |
), |
| 305 |
), |
| 306 |
), |
| 307 |
array( |
| 308 |
'id' => 'upsells_add_to_cart_text', |
| 309 |
'title' => __( 'Button text', 'merchant' ), |
| 310 |
'type' => 'text', |
| 311 |
'default' => __( 'Add', 'merchant' ), |
| 312 |
'conditions' => array( |
| 313 |
'relation' => 'AND', // AND/OR, If not provided, only first term will be considered |
| 314 |
'terms' => array( |
| 315 |
array( |
| 316 |
'field' => 'use_upsells', // field ID |
| 317 |
'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains |
| 318 |
'value' => true, // can be a single value or an array of string/number/int |
| 319 |
), |
| 320 |
), |
| 321 |
), |
| 322 |
), |
| 323 |
array( |
| 324 |
'id' => 'upsells_style', |
| 325 |
'type' => 'select', |
| 326 |
'title' => esc_html__( 'Upsell direction', 'merchant' ), |
| 327 |
'options' => array( |
| 328 |
'carousel' => esc_html__( 'Carousel', 'merchant' ), |
| 329 |
'block' => esc_html__( 'Block', 'merchant' ), |
| 330 |
), |
| 331 |
'default' => 'block', |
| 332 |
'conditions' => array( |
| 333 |
'relation' => 'AND', // AND/OR, If not provided, only first term will be considered |
| 334 |
'terms' => array( |
| 335 |
array( |
| 336 |
'field' => 'use_upsells', // field ID |
| 337 |
'operator' => '===', // Available operators: ===, !==, >, <, >=, <=, in, !in, contains, !contains |
| 338 |
'value' => true, // can be a single value or an array of string/number/int |
| 339 |
), |
| 340 |
), |
| 341 |
), |
| 342 |
), |
| 343 |
), |
| 344 |
) ); |
| 345 |
|
| 346 |
// Side Cart Settings |
| 347 |
Merchant_Admin_Options::create( array( |
| 348 |
'title' => esc_html__( 'Look and Feel', 'merchant' ), |
| 349 |
'module' => 'floating-mini-cart', |
| 350 |
'fields' => array( |
| 351 |
|
| 352 |
array( |
| 353 |
'id' => 'side-cart-width', |
| 354 |
'type' => 'range', |
| 355 |
'title' => esc_html__( 'Side cart width', 'merchant' ), |
| 356 |
'min' => 0, |
| 357 |
'max' => 2000, |
| 358 |
'step' => 1, |
| 359 |
'default' => 380, |
| 360 |
'unit' => 'px', |
| 361 |
), |
| 362 |
|
| 363 |
array( |
| 364 |
'id' => 'side-cart-title-color', |
| 365 |
'type' => 'color', |
| 366 |
'title' => esc_html__( 'Title color', 'merchant' ), |
| 367 |
'default' => '#212121', |
| 368 |
), |
| 369 |
|
| 370 |
array( |
| 371 |
'id' => 'side-cart-title-icon-color', |
| 372 |
'type' => 'color', |
| 373 |
'title' => esc_html__( 'Title icon color', 'merchant' ), |
| 374 |
'default' => '#212121', |
| 375 |
), |
| 376 |
|
| 377 |
array( |
| 378 |
'id' => 'side-cart-title-background-color', |
| 379 |
'type' => 'color', |
| 380 |
'title' => esc_html__( 'Title background color', 'merchant' ), |
| 381 |
'default' => '#cccccc', |
| 382 |
), |
| 383 |
|
| 384 |
array( |
| 385 |
'id' => 'side-cart-content-text-color', |
| 386 |
'type' => 'color', |
| 387 |
'title' => esc_html__( 'Content text color', 'merchant' ), |
| 388 |
'default' => '#212121', |
| 389 |
), |
| 390 |
|
| 391 |
array( |
| 392 |
'id' => 'side-cart-content-background-color', |
| 393 |
'type' => 'color', |
| 394 |
'title' => esc_html__( 'Content background color', 'merchant' ), |
| 395 |
'default' => '#ffffff', |
| 396 |
), |
| 397 |
|
| 398 |
array( |
| 399 |
'id' => 'side-cart-content-remove-color', |
| 400 |
'type' => 'color', |
| 401 |
'title' => esc_html__( 'Content (x) color', 'merchant' ), |
| 402 |
'default' => '#ffffff', |
| 403 |
), |
| 404 |
|
| 405 |
array( |
| 406 |
'id' => 'side-cart-content-remove-background-color', |
| 407 |
'type' => 'color', |
| 408 |
'title' => esc_html__( 'Content (x) background color', 'merchant' ), |
| 409 |
'default' => '#212121', |
| 410 |
), |
| 411 |
|
| 412 |
array( |
| 413 |
'id' => 'side-cart-total-text-color', |
| 414 |
'type' => 'color', |
| 415 |
'title' => esc_html__( 'Total text color', 'merchant' ), |
| 416 |
'default' => '#212121', |
| 417 |
), |
| 418 |
|
| 419 |
array( |
| 420 |
'id' => 'side-cart-total-background-color', |
| 421 |
'type' => 'color', |
| 422 |
'title' => esc_html__( 'Total background color', 'merchant' ), |
| 423 |
'default' => '#f5f5f5', |
| 424 |
), |
| 425 |
|
| 426 |
array( |
| 427 |
'id' => 'side-cart-button-color', |
| 428 |
'type' => 'color', |
| 429 |
'title' => esc_html__( 'Button color', 'merchant' ), |
| 430 |
'default' => '#ffffff', |
| 431 |
), |
| 432 |
|
| 433 |
array( |
| 434 |
'id' => 'side-cart-button-color-hover', |
| 435 |
'type' => 'color', |
| 436 |
'title' => esc_html__( 'Button color hover', 'merchant' ), |
| 437 |
'default' => '#ffffff', |
| 438 |
), |
| 439 |
|
| 440 |
array( |
| 441 |
'id' => 'side-cart-button-border-color', |
| 442 |
'type' => 'color', |
| 443 |
'title' => esc_html__( 'Button border color', 'merchant' ), |
| 444 |
'default' => '#212121', |
| 445 |
), |
| 446 |
|
| 447 |
array( |
| 448 |
'id' => 'side-cart-button-border-color-hover', |
| 449 |
'type' => 'color', |
| 450 |
'title' => esc_html__( 'Button border color hover', 'merchant' ), |
| 451 |
'default' => '#313131', |
| 452 |
), |
| 453 |
|
| 454 |
array( |
| 455 |
'id' => 'side-cart-button-background-color', |
| 456 |
'type' => 'color', |
| 457 |
'title' => esc_html__( 'Button background color', 'merchant' ), |
| 458 |
'default' => '#212121', |
| 459 |
), |
| 460 |
|
| 461 |
array( |
| 462 |
'id' => 'side-cart-button-background-color-hover', |
| 463 |
'type' => 'color', |
| 464 |
'title' => esc_html__( 'Button background color hover', 'merchant' ), |
| 465 |
'default' => '#313131', |
| 466 |
), |
| 467 |
|
| 468 |
), |
| 469 |
) ); |
| 470 |
|