| 1 |
<?php |
| 2 |
/** |
| 3 |
* Merchant - Product Labels |
| 4 |
*/ |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) { |
| 7 |
exit; // Exit if accessed directly |
| 8 |
} |
| 9 |
|
| 10 |
$text_shapes = array(); |
| 11 |
$image_shapes = array(); |
| 12 |
|
| 13 |
for ( $i = 1; $i <= 24; $i++ ) { |
| 14 |
if ( $i <= 8 ) { |
| 15 |
$text_shapes[ 'text-shape-' . $i ] = MERCHANT_URI . 'assets/images/icons/product-labels/text-shape-' . $i . '.svg'; |
| 16 |
} |
| 17 |
|
| 18 |
$image_shapes[ 'image-shape-' . $i ] = MERCHANT_URI . 'assets/images/icons/product-labels/image-shape-' . $i . '.svg'; |
| 19 |
} |
| 20 |
|
| 21 |
$display_rules = array( |
| 22 |
'featured_products' => esc_html__( 'Featured Products', 'merchant' ), |
| 23 |
'products_on_sale' => esc_html__( 'Products on Sale', 'merchant' ), |
| 24 |
'new_products' => esc_html__( 'New Products', 'merchant' ), |
| 25 |
'out_of_stock' => esc_html__( 'Out of Stock Products', 'merchant' ), |
| 26 |
'all_products' => esc_html__( 'All Products', 'merchant' ), |
| 27 |
'specific_products' => esc_html__( 'Specific Products', 'merchant' ), |
| 28 |
'by_category' => esc_html__( 'Specific Categories', 'merchant' ), |
| 29 |
'by_tags' => esc_html__( 'Specific Tags', 'merchant' ), |
| 30 |
'by_brands' => esc_html__( 'Specific Brands', 'merchant' ), |
| 31 |
); |
| 32 |
|
| 33 |
/** |
| 34 |
* `merchant_product_labels_display_rules` |
| 35 |
* |
| 36 |
* @since 1.10.1 |
| 37 |
*/ |
| 38 |
$display_rules = apply_filters( 'merchant_product_labels_display_rules', $display_rules, Merchant_Product_Labels::MODULE_ID ); |
| 39 |
|
| 40 |
/** |
| 41 |
* Settings |
| 42 |
*/ |
| 43 |
|
| 44 |
return array( |
| 45 |
array( |
| 46 |
'title' => esc_html__( 'Settings', 'merchant' ), |
| 47 |
'module' => Merchant_Product_Labels::MODULE_ID, |
| 48 |
'fields' => array( |
| 49 |
array( |
| 50 |
'id' => 'labels', |
| 51 |
'type' => 'flexible_content', |
| 52 |
'sorting' => true, |
| 53 |
'accordion' => true, |
| 54 |
'duplicate' => true, |
| 55 |
'style' => Merchant_Product_Labels::MODULE_ID . '-style default', |
| 56 |
'button_label' => esc_html__( 'Add New Label', 'merchant' ), |
| 57 |
'layouts' => array( |
| 58 |
'single-label' => array( |
| 59 |
'title' => esc_html__( 'Product label', 'merchant' ), |
| 60 |
'title-field' => 'label-title', |
| 61 |
'status-field' => 'campaign_status', |
| 62 |
'fields' => array( |
| 63 |
array( |
| 64 |
'id' => 'campaign_status', |
| 65 |
'type' => 'select', |
| 66 |
'title' => esc_html__( 'Status', 'merchant' ), |
| 67 |
'options' => array( |
| 68 |
'active' => esc_html__( 'Active', 'merchant' ), |
| 69 |
'inactive' => esc_html__( 'Inactive', 'merchant' ), |
| 70 |
), |
| 71 |
'default' => 'active', |
| 72 |
'ai_meta' => array( |
| 73 |
'usage_hint' => 'Controls whether this label is active or inactive.', |
| 74 |
), |
| 75 |
), |
| 76 |
array( |
| 77 |
'id' => 'label-title', |
| 78 |
'title' => esc_html__( 'Label name', 'merchant' ), |
| 79 |
'desc' => esc_html__( 'Internal label name. This is not visible to customers.', 'merchant' ), |
| 80 |
'type' => 'text', |
| 81 |
'default' => esc_html__( 'Product label', 'merchant' ), |
| 82 |
), |
| 83 |
|
| 84 |
array( |
| 85 |
'id' => 'label_type', |
| 86 |
'type' => 'buttons_content', |
| 87 |
'title' => '', |
| 88 |
'desc' => '', |
| 89 |
'options' => array( |
| 90 |
'text' => array( |
| 91 |
'title' => esc_html__( 'Text', 'merchant' ), |
| 92 |
'desc' => esc_html__( 'Add text label', 'merchant' ), |
| 93 |
'icon' => MERCHANT_URI . 'assets/images/icons/product-labels/text-icon.svg', |
| 94 |
), |
| 95 |
'image' => array( |
| 96 |
'title' => esc_html__( 'Image', 'merchant' ), |
| 97 |
'desc' => esc_html__( 'Add image label', 'merchant' ), |
| 98 |
'icon' => MERCHANT_URI . 'assets/images/icons/product-labels/image-icon.svg', |
| 99 |
), |
| 100 |
), |
| 101 |
'default' => 'text', |
| 102 |
), |
| 103 |
|
| 104 |
array( |
| 105 |
'id' => 'label', |
| 106 |
'title' => esc_html__( 'Label content', 'merchant' ), |
| 107 |
'type' => 'text', |
| 108 |
'default' => esc_html__( 'SALE', 'merchant' ), |
| 109 |
'desc' => __( 'You can use these codes in the content.', 'merchant' ), |
| 110 |
'hidden_desc' => sprintf( |
| 111 |
/* Translators: %1$s: Discount percentage, %2$s: Discount amount, %3$s: In Stock, %4$s: Total quantity */ |
| 112 |
__( |
| 113 |
'<strong>%1$s:</strong> to show discount percentage<br><strong>%2$s:</strong> to show discount amount<br><strong>%3$s:</strong> to show In Stock, Sold Out<br><strong>%4$s:</strong> to show total quantity in inventory', |
| 114 |
'merchant' |
| 115 |
), |
| 116 |
'{sale}', |
| 117 |
'{sale_amount}', |
| 118 |
'{inventory}', |
| 119 |
'{inventory_quantity}' |
| 120 |
), |
| 121 |
'condition' => array( 'label_type', '==', 'text' ), |
| 122 |
), |
| 123 |
|
| 124 |
array( |
| 125 |
'id' => 'label_text_shape', |
| 126 |
'type' => 'choices', |
| 127 |
'title' => esc_html__( 'Label shape', 'merchant' ), |
| 128 |
'options' => $text_shapes, |
| 129 |
'default' => 'text-shape-1', |
| 130 |
'condition' => array( 'label_type', '==', 'text' ), |
| 131 |
), |
| 132 |
|
| 133 |
array( |
| 134 |
'id' => 'label_image_shape', |
| 135 |
'type' => 'choices', |
| 136 |
'title' => esc_html__( 'Image label', 'merchant' ), |
| 137 |
'options' => $image_shapes, |
| 138 |
'default' => 'image-shape-1', |
| 139 |
'condition' => array( 'label_type', '==', 'image' ), |
| 140 |
), |
| 141 |
|
| 142 |
array( |
| 143 |
'id' => 'label_image_shape_custom', |
| 144 |
'type' => 'upload', |
| 145 |
'drag_drop' => true, |
| 146 |
'title' => esc_html__( 'Upload custom image label', 'merchant' ), |
| 147 |
'label' => esc_html__( 'Click to upload or drag and drop', 'merchant' ), |
| 148 |
'condition' => array( 'label_type', '==', 'image' ), |
| 149 |
), |
| 150 |
|
| 151 |
array( |
| 152 |
'id' => 'position_anchor', |
| 153 |
'type' => 'select', |
| 154 |
'title' => esc_html__( 'Anchor Point', 'merchant' ), |
| 155 |
'desc' => esc_html__( 'Which point of the label to use as the anchor for positioning.', 'merchant' ), |
| 156 |
'options' => array( |
| 157 |
'top-left' => esc_html__( 'Top Left', 'merchant' ), |
| 158 |
'top-right' => esc_html__( 'Top Right', 'merchant' ), |
| 159 |
), |
| 160 |
'default' => 'top-left', |
| 161 |
), |
| 162 |
|
| 163 |
array( |
| 164 |
'id' => 'position_x', |
| 165 |
'type' => 'range', |
| 166 |
'title' => esc_html__( 'Horizontal Position (X)', 'merchant' ), |
| 167 |
'desc' => esc_html__( 'Horizontal position from left edge.', 'merchant' ), |
| 168 |
'min' => -300, |
| 169 |
'max' => 300, |
| 170 |
'step' => 1, |
| 171 |
'default' => 0, |
| 172 |
'unit' => 'px', |
| 173 |
), |
| 174 |
|
| 175 |
array( |
| 176 |
'id' => 'position_y', |
| 177 |
'type' => 'range', |
| 178 |
'title' => esc_html__( 'Vertical Position (Y)', 'merchant' ), |
| 179 |
'desc' => esc_html__( 'Vertical position from top edge.', 'merchant' ), |
| 180 |
'min' => -300, |
| 181 |
'max' => 300, |
| 182 |
'step' => 1, |
| 183 |
'default' => 0, |
| 184 |
'unit' => 'px', |
| 185 |
), |
| 186 |
|
| 187 |
array( |
| 188 |
'id' => 'label_width', |
| 189 |
'type' => 'range', |
| 190 |
'title' => esc_html__( 'Label width', 'merchant' ), |
| 191 |
'min' => 1, |
| 192 |
'max' => 1000, |
| 193 |
'step' => 1, |
| 194 |
'default' => 100, |
| 195 |
'unit' => 'px', |
| 196 |
), |
| 197 |
array( |
| 198 |
'id' => 'label_height', |
| 199 |
'type' => 'range', |
| 200 |
'title' => esc_html__( 'Label height', 'merchant' ), |
| 201 |
'min' => 1, |
| 202 |
'max' => 250, |
| 203 |
'step' => 1, |
| 204 |
'default' => 32, |
| 205 |
'unit' => 'px', |
| 206 |
), |
| 207 |
|
| 208 |
array( |
| 209 |
'id' => 'background_color', |
| 210 |
'type' => 'color', |
| 211 |
'title' => esc_html__( 'Background color', 'merchant' ), |
| 212 |
'default' => '#212121', |
| 213 |
'condition' => array( 'label_type', '==', 'text' ), |
| 214 |
), |
| 215 |
|
| 216 |
array( |
| 217 |
'id' => 'shape_radius', |
| 218 |
'type' => 'range', |
| 219 |
'title' => esc_html__( 'Shape radius', 'merchant' ), |
| 220 |
'min' => 0, |
| 221 |
'max' => 250, |
| 222 |
'step' => 1, |
| 223 |
'unit' => 'px', |
| 224 |
'default' => 5, |
| 225 |
'condition' => array( 'label_type', '==', 'text' ), |
| 226 |
), |
| 227 |
|
| 228 |
array( |
| 229 |
'id' => 'font_size', |
| 230 |
'type' => 'range', |
| 231 |
'title' => esc_html__( 'Font size', 'merchant' ), |
| 232 |
'min' => 0, |
| 233 |
'max' => 250, |
| 234 |
'step' => 1, |
| 235 |
'unit' => 'px', |
| 236 |
'default' => 14, |
| 237 |
'condition' => array( 'label_type', '==', 'text' ), |
| 238 |
), |
| 239 |
|
| 240 |
array( |
| 241 |
'id' => 'font_style', |
| 242 |
'type' => 'select', |
| 243 |
'title' => esc_html__( 'Font style', 'merchant' ), |
| 244 |
'options' => array( |
| 245 |
'normal' => esc_html__( 'Normal', 'merchant' ), |
| 246 |
'italic' => esc_html__( 'Italic', 'merchant' ), |
| 247 |
'bold' => esc_html__( 'Bold', 'merchant' ), |
| 248 |
'bold_italic' => esc_html__( 'Bold Italic', 'merchant' ), |
| 249 |
), |
| 250 |
'default' => 'normal', |
| 251 |
'condition' => array( 'label_type', '==', 'text' ), |
| 252 |
), |
| 253 |
|
| 254 |
array( |
| 255 |
'id' => 'text_color', |
| 256 |
'type' => 'color', |
| 257 |
'title' => esc_html__( 'Font color', 'merchant' ), |
| 258 |
'default' => '#ffffff', |
| 259 |
'condition' => array( 'label_type', '==', 'text' ), |
| 260 |
), |
| 261 |
|
| 262 |
array( |
| 263 |
'id' => 'display_rules', |
| 264 |
'type' => 'select', |
| 265 |
'title' => esc_html__( 'Product trigger', 'merchant' ), |
| 266 |
'options' => $display_rules, |
| 267 |
'default' => 'products_on_sale', |
| 268 |
'ai_meta' => array( |
| 269 |
'semantic_group' => 'product_targeting', |
| 270 |
'usage_hint' => 'Which products this label appears on. Set this BEFORE setting product_cats, product_tags, product_brands, or product_ids — those fields are conditional on this value.', |
| 271 |
), |
| 272 |
), |
| 273 |
|
| 274 |
array( |
| 275 |
'id' => 'new_products_days', |
| 276 |
'type' => 'number', |
| 277 |
'min' => 0, |
| 278 |
'step' => 1, |
| 279 |
'title' => esc_html__( 'How long counts as new', 'merchant' ), |
| 280 |
'desc' => esc_html__( 'Set the number of days the product will be marked as ‘New’ after it has been created', 'merchant' ), |
| 281 |
'default' => 3, |
| 282 |
'condition' => array( 'display_rules', '==', 'new_products' ), |
| 283 |
'ai_meta' => array( |
| 284 |
'semantic_group' => 'offer_rules', |
| 285 |
'usage_hint' => 'Number of days after publication during which a product is considered "new". Only used when display_rules is new_products.', |
| 286 |
), |
| 287 |
), |
| 288 |
|
| 289 |
array( |
| 290 |
'id' => 'product_cats', |
| 291 |
'type' => 'select_ajax', |
| 292 |
'title' => esc_html__( 'Categories', 'merchant' ), |
| 293 |
'source' => 'options', |
| 294 |
'multiple' => true, |
| 295 |
'options' => Merchant_Admin_Options::get_category_select2_choices(), |
| 296 |
'placeholder' => esc_html__( 'Select categories', 'merchant' ), |
| 297 |
'desc' => esc_html__( 'Select the product categories that will show the label.', 'merchant' ), |
| 298 |
'condition' => array( 'display_rules', '==', 'by_category' ), |
| 299 |
'ai_meta' => array( |
| 300 |
'entity' => 'category', |
| 301 |
'reference_type' => 'dynamic', |
| 302 |
'taxonomy' => 'product_cat', |
| 303 |
'value_format' => 'slug', |
| 304 |
'semantic_group' => 'product_targeting', |
| 305 |
'abstraction_level' => 3, |
| 306 |
'usage_hint' => 'Categories that show this label. Only used when display_rules is by_category.', |
| 307 |
), |
| 308 |
), |
| 309 |
|
| 310 |
array( |
| 311 |
'id' => 'product_tags', |
| 312 |
'type' => 'select_ajax', |
| 313 |
'title' => esc_html__( 'Tags', 'merchant' ), |
| 314 |
'source' => 'options', |
| 315 |
'multiple' => true, |
| 316 |
'options' => Merchant_Admin_Options::get_tag_select2_choices(), |
| 317 |
'placeholder' => esc_html__( 'Select tags', 'merchant' ), |
| 318 |
'desc' => esc_html__( 'Select the product tags that will show the label.', 'merchant' ), |
| 319 |
'condition' => array( 'display_rules', '==', 'by_tags' ), |
| 320 |
'ai_meta' => array( |
| 321 |
'entity' => 'tag', |
| 322 |
'reference_type' => 'dynamic', |
| 323 |
'taxonomy' => 'product_tag', |
| 324 |
'value_format' => 'slug', |
| 325 |
'semantic_group' => 'product_targeting', |
| 326 |
'abstraction_level' => 2, |
| 327 |
'usage_hint' => 'Tags that show this label. Only used when display_rules is by_tags.', |
| 328 |
), |
| 329 |
), |
| 330 |
|
| 331 |
array( |
| 332 |
'id' => 'product_brands', |
| 333 |
'type' => 'select_ajax', |
| 334 |
'title' => esc_html__( 'Brands', 'merchant' ), |
| 335 |
'source' => 'options', |
| 336 |
'multiple' => true, |
| 337 |
'options' => Merchant_Admin_Options::get_brand_select2_choices(), |
| 338 |
'placeholder' => esc_html__( 'Select brands', 'merchant' ), |
| 339 |
'desc' => esc_html__( 'Select the product brands that will show the label.', 'merchant' ), |
| 340 |
'condition' => array( 'display_rules', '==', 'by_brands' ), |
| 341 |
'ai_meta' => array( |
| 342 |
'entity' => 'brand', |
| 343 |
'reference_type' => 'dynamic', |
| 344 |
'taxonomy' => 'product_brand', |
| 345 |
'value_format' => 'slug', |
| 346 |
'semantic_group' => 'product_targeting', |
| 347 |
'abstraction_level' => 4, |
| 348 |
'usage_hint' => 'Brands that show this label. Only used when display_rules is by_brands.', |
| 349 |
), |
| 350 |
), |
| 351 |
|
| 352 |
array( |
| 353 |
'id' => 'product_ids', |
| 354 |
'type' => 'products_selector', |
| 355 |
'multiple' => true, |
| 356 |
'desc' => esc_html__( 'Select the products that will show the label.', 'merchant' ), |
| 357 |
'allowed_types' => array( 'simple', 'variable' ), |
| 358 |
'condition' => array( 'display_rules', '==', 'specific_products' ), |
| 359 |
'ai_meta' => array( |
| 360 |
'entity' => 'product', |
| 361 |
'reference_type' => 'static', |
| 362 |
'value_format' => 'product_id', |
| 363 |
'semantic_group' => 'product_targeting', |
| 364 |
'abstraction_level' => 1, |
| 365 |
'usage_hint' => 'Specific product IDs that show this label. Only used when display_rules is specific_products.', |
| 366 |
), |
| 367 |
), |
| 368 |
|
| 369 |
array( |
| 370 |
'id' => 'exclude_products_toggle', |
| 371 |
'type' => 'switcher', |
| 372 |
'title' => esc_html__( 'Exclude Products', 'merchant' ), |
| 373 |
'desc' => esc_html__( 'Exclude specific products from this label.', 'merchant' ), |
| 374 |
'default' => 0, |
| 375 |
'conditions' => array( |
| 376 |
'relation' => 'AND', |
| 377 |
'terms' => array( |
| 378 |
array( |
| 379 |
'field' => 'display_rules', |
| 380 |
'operator' => 'in', |
| 381 |
'value' => array( 'all_products', 'by_category', 'by_tags', 'by_brands', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ), |
| 382 |
), |
| 383 |
), |
| 384 |
), |
| 385 |
'ai_meta' => array( |
| 386 |
'toggle_for' => 'excluded_products', |
| 387 |
'semantic_group' => 'product_exclusion', |
| 388 |
'usage_hint' => 'Enable this to reveal the excluded_products field.', |
| 389 |
), |
| 390 |
), |
| 391 |
|
| 392 |
array( |
| 393 |
'id' => 'excluded_products', |
| 394 |
'type' => 'products_selector', |
| 395 |
'title' => esc_html__( 'Excluded Products List', 'merchant' ), |
| 396 |
'desc' => esc_html__( 'Exclude products from this label.', 'merchant' ), |
| 397 |
'multiple' => true, |
| 398 |
'allowed_types' => array( 'simple', 'variable' ), |
| 399 |
'conditions' => array( |
| 400 |
'relation' => 'AND', |
| 401 |
'terms' => array( |
| 402 |
array( |
| 403 |
'field' => 'display_rules', |
| 404 |
'operator' => 'in', |
| 405 |
'value' => array( 'all_products', 'by_category', 'by_tags', 'by_brands', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ), |
| 406 |
), |
| 407 |
array( |
| 408 |
'field' => 'exclude_products_toggle', |
| 409 |
'operator' => '===', |
| 410 |
'value' => true, |
| 411 |
), |
| 412 |
), |
| 413 |
), |
| 414 |
'ai_meta' => array( |
| 415 |
'entity' => 'product', |
| 416 |
'reference_type' => 'static', |
| 417 |
'value_format' => 'product_id', |
| 418 |
'semantic_group' => 'product_exclusion', |
| 419 |
'abstraction_level' => 1, |
| 420 |
'toggled_by' => 'exclude_products_toggle', |
| 421 |
'usage_hint' => 'Products excluded from showing this label. Requires exclude_products_toggle.', |
| 422 |
), |
| 423 |
), |
| 424 |
|
| 425 |
array( |
| 426 |
'id' => 'exclude_categories_toggle', |
| 427 |
'type' => 'switcher', |
| 428 |
'title' => esc_html__( 'Exclude Categories', 'merchant' ), |
| 429 |
'desc' => esc_html__( 'Exclude specific categories from this label.', 'merchant' ), |
| 430 |
'default' => 0, |
| 431 |
'conditions' => array( |
| 432 |
'relation' => 'AND', |
| 433 |
'terms' => array( |
| 434 |
array( |
| 435 |
'field' => 'display_rules', |
| 436 |
'operator' => 'in', |
| 437 |
'value' => array( 'all_products', 'by_tags', 'by_brands', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ), |
| 438 |
), |
| 439 |
), |
| 440 |
), |
| 441 |
'ai_meta' => array( |
| 442 |
'toggle_for' => 'excluded_categories', |
| 443 |
'semantic_group' => 'product_exclusion', |
| 444 |
'usage_hint' => 'Enable this to reveal the excluded_categories field.', |
| 445 |
), |
| 446 |
), |
| 447 |
|
| 448 |
array( |
| 449 |
'id' => 'excluded_categories', |
| 450 |
'type' => 'select_ajax', |
| 451 |
'title' => esc_html__( 'Excluded Categories List', 'merchant' ), |
| 452 |
'source' => 'options', |
| 453 |
'multiple' => true, |
| 454 |
'options' => Merchant_Admin_Options::get_category_select2_choices(), |
| 455 |
'placeholder' => esc_html__( 'Select categories', 'merchant' ), |
| 456 |
'desc' => esc_html__( 'Exclude categories from this label.', 'merchant' ), |
| 457 |
'conditions' => array( |
| 458 |
'relation' => 'AND', |
| 459 |
'terms' => array( |
| 460 |
array( |
| 461 |
'field' => 'display_rules', |
| 462 |
'operator' => 'in', |
| 463 |
'value' => array( 'all_products', 'by_tags', 'by_brands', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ), |
| 464 |
), |
| 465 |
array( |
| 466 |
'field' => 'exclude_categories_toggle', |
| 467 |
'operator' => '===', |
| 468 |
'value' => true, |
| 469 |
), |
| 470 |
), |
| 471 |
), |
| 472 |
'ai_meta' => array( |
| 473 |
'entity' => 'category', |
| 474 |
'reference_type' => 'dynamic', |
| 475 |
'taxonomy' => 'product_cat', |
| 476 |
'value_format' => 'slug', |
| 477 |
'semantic_group' => 'product_exclusion', |
| 478 |
'abstraction_level' => 3, |
| 479 |
'toggled_by' => 'exclude_categories_toggle', |
| 480 |
'usage_hint' => 'Categories excluded from this label. Requires exclude_categories_toggle.', |
| 481 |
), |
| 482 |
), |
| 483 |
|
| 484 |
array( |
| 485 |
'id' => 'exclude_tags_toggle', |
| 486 |
'type' => 'switcher', |
| 487 |
'title' => esc_html__( 'Exclude Tags', 'merchant' ), |
| 488 |
'desc' => esc_html__( 'Exclude specific tags from this label.', 'merchant' ), |
| 489 |
'default' => 0, |
| 490 |
'conditions' => array( |
| 491 |
'relation' => 'AND', |
| 492 |
'terms' => array( |
| 493 |
array( |
| 494 |
'field' => 'display_rules', |
| 495 |
'operator' => 'in', |
| 496 |
'value' => array( 'all_products', 'by_category', 'by_brands', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ), |
| 497 |
), |
| 498 |
), |
| 499 |
), |
| 500 |
'ai_meta' => array( |
| 501 |
'toggle_for' => 'excluded_tags', |
| 502 |
'semantic_group' => 'product_exclusion', |
| 503 |
'usage_hint' => 'Enable this to reveal the excluded_tags field.', |
| 504 |
), |
| 505 |
), |
| 506 |
|
| 507 |
array( |
| 508 |
'id' => 'excluded_tags', |
| 509 |
'type' => 'select_ajax', |
| 510 |
'title' => esc_html__( 'Excluded Tags List', 'merchant' ), |
| 511 |
'source' => 'options', |
| 512 |
'multiple' => true, |
| 513 |
'options' => Merchant_Admin_Options::get_tag_select2_choices(), |
| 514 |
'placeholder' => esc_html__( 'Select tags', 'merchant' ), |
| 515 |
'desc' => esc_html__( 'Exclude tags from this label.', 'merchant' ), |
| 516 |
'conditions' => array( |
| 517 |
'relation' => 'AND', |
| 518 |
'terms' => array( |
| 519 |
array( |
| 520 |
'field' => 'display_rules', |
| 521 |
'operator' => 'in', |
| 522 |
'value' => array( 'all_products', 'by_category', 'by_brands', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ), |
| 523 |
), |
| 524 |
array( |
| 525 |
'field' => 'exclude_tags_toggle', |
| 526 |
'operator' => '===', |
| 527 |
'value' => true, |
| 528 |
), |
| 529 |
), |
| 530 |
), |
| 531 |
'ai_meta' => array( |
| 532 |
'entity' => 'tag', |
| 533 |
'reference_type' => 'dynamic', |
| 534 |
'taxonomy' => 'product_tag', |
| 535 |
'value_format' => 'slug', |
| 536 |
'semantic_group' => 'product_exclusion', |
| 537 |
'abstraction_level' => 2, |
| 538 |
'toggled_by' => 'exclude_tags_toggle', |
| 539 |
'usage_hint' => 'Tags excluded from this label. Requires exclude_tags_toggle.', |
| 540 |
), |
| 541 |
), |
| 542 |
|
| 543 |
array( |
| 544 |
'id' => 'exclude_brands_toggle', |
| 545 |
'type' => 'switcher', |
| 546 |
'title' => esc_html__( 'Exclude Brands', 'merchant' ), |
| 547 |
'desc' => esc_html__( 'Exclude specific brands from this label.', 'merchant' ), |
| 548 |
'default' => 0, |
| 549 |
'conditions' => array( |
| 550 |
'relation' => 'AND', |
| 551 |
'terms' => array( |
| 552 |
array( |
| 553 |
'field' => 'display_rules', |
| 554 |
'operator' => 'in', |
| 555 |
'value' => array( 'all_products', 'by_category', 'by_tags', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ), |
| 556 |
), |
| 557 |
), |
| 558 |
), |
| 559 |
'ai_meta' => array( |
| 560 |
'toggle_for' => 'excluded_brands', |
| 561 |
'semantic_group' => 'product_exclusion', |
| 562 |
'usage_hint' => 'Enable this to reveal the excluded_brands field.', |
| 563 |
), |
| 564 |
), |
| 565 |
|
| 566 |
array( |
| 567 |
'id' => 'excluded_brands', |
| 568 |
'type' => 'select_ajax', |
| 569 |
'title' => esc_html__( 'Excluded Brands List', 'merchant' ), |
| 570 |
'source' => 'options', |
| 571 |
'multiple' => true, |
| 572 |
'options' => Merchant_Admin_Options::get_brand_select2_choices(), |
| 573 |
'placeholder' => esc_html__( 'Select brands', 'merchant' ), |
| 574 |
'desc' => esc_html__( 'Exclude brands from this label.', 'merchant' ), |
| 575 |
'conditions' => array( |
| 576 |
'relation' => 'AND', |
| 577 |
'terms' => array( |
| 578 |
array( |
| 579 |
'field' => 'display_rules', |
| 580 |
'operator' => 'in', |
| 581 |
'value' => array( 'all_products', 'by_category', 'by_tags', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ), |
| 582 |
), |
| 583 |
array( |
| 584 |
'field' => 'exclude_brands_toggle', |
| 585 |
'operator' => '===', |
| 586 |
'value' => true, |
| 587 |
), |
| 588 |
), |
| 589 |
), |
| 590 |
'ai_meta' => array( |
| 591 |
'entity' => 'brand', |
| 592 |
'reference_type' => 'dynamic', |
| 593 |
'taxonomy' => 'product_brand', |
| 594 |
'value_format' => 'slug', |
| 595 |
'semantic_group' => 'product_exclusion', |
| 596 |
'abstraction_level' => 4, |
| 597 |
'toggled_by' => 'exclude_brands_toggle', |
| 598 |
'usage_hint' => 'Brands excluded from this label. Requires exclude_brands_toggle.', |
| 599 |
), |
| 600 |
), |
| 601 |
|
| 602 |
array( |
| 603 |
'id' => 'show_pages', |
| 604 |
'type' => 'checkbox_multiple', |
| 605 |
'title' => esc_html__( 'Show on pages', 'merchant' ), |
| 606 |
'options' => array( |
| 607 |
'homepage' => esc_html__( 'Homepage', 'merchant' ), |
| 608 |
'single' => esc_html__( 'Product Single', 'merchant' ), |
| 609 |
'archive' => esc_html__( 'Product Archive', 'merchant' ), |
| 610 |
), |
| 611 |
'default' => array( 'homepage', 'single', 'archive' ), |
| 612 |
), |
| 613 |
|
| 614 |
array( |
| 615 |
'id' => 'show_devices', |
| 616 |
'type' => 'checkbox_multiple', |
| 617 |
'title' => esc_html__( 'Show on devices', 'merchant' ), |
| 618 |
'options' => array( |
| 619 |
'desktop' => esc_html__( 'Desktop', 'merchant' ), |
| 620 |
'mobile' => esc_html__( 'Mobile', 'merchant' ), |
| 621 |
), |
| 622 |
'default' => array( 'desktop', 'mobile' ), |
| 623 |
), |
| 624 |
), |
| 625 |
), |
| 626 |
), |
| 627 |
'default' => array( |
| 628 |
array( |
| 629 |
'layout' => 'single-label', |
| 630 |
'label' => esc_html__( 'SALE', 'merchant' ), |
| 631 |
'display_rules' => 'featured_products', |
| 632 |
), |
| 633 |
), |
| 634 |
), |
| 635 |
array( |
| 636 |
'id' => 'multiple_labels', |
| 637 |
'type' => 'switcher', |
| 638 |
'title' => __( 'Use multiple labels', 'merchant' ), |
| 639 |
'desc' => __( 'Enable this to display multiple labels assigned to the product when multiple labels are available.', 'merchant' ), |
| 640 |
'default' => 0, |
| 641 |
), |
| 642 |
), |
| 643 |
), |
| 644 |
array( |
| 645 |
'module' => Merchant_Product_Labels::MODULE_ID, |
| 646 |
'title' => esc_html__( 'Use shortcode', 'merchant' ), |
| 647 |
'fields' => array( |
| 648 |
array( |
| 649 |
'id' => 'use_shortcode', |
| 650 |
'type' => 'switcher', |
| 651 |
'title' => __( 'Use shortcode', 'merchant' ), |
| 652 |
'default' => 0, |
| 653 |
), |
| 654 |
array( |
| 655 |
'type' => 'info', |
| 656 |
'id' => 'shortcode_info', |
| 657 |
'content' => esc_html__( 'If you are using a page builder or a theme that supports shortcodes, then you can output the module using the shortcode above. This might be useful if, for example, you find that you want to control the position of the module output more precisely than with the module settings. Note that the shortcodes can only be used on single product pages.', 'merchant' ), |
| 658 |
), |
| 659 |
array( |
| 660 |
'id' => 'shortcode_text', |
| 661 |
'type' => 'text_readonly', |
| 662 |
'title' => esc_html__( 'Shortcode text', 'merchant' ), |
| 663 |
'default' => '[merchant_module_' . str_replace( '-', '_', Merchant_Product_Labels::MODULE_ID ) . ']', |
| 664 |
'condition' => array( 'use_shortcode', '==', '1' ), |
| 665 |
), |
| 666 |
), |
| 667 |
), |
| 668 |
); |
| 669 |
|