| 1 |
<?php |
| 2 |
/** |
| 3 |
* Buy Now — Admin Options. |
| 4 |
* |
| 5 |
* Defines the campaign-based flexible_content repeater and global settings sections. |
| 6 |
* |
| 7 |
* @package Merchant |
| 8 |
*/ |
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; // Exit if accessed directly |
| 12 |
} |
| 13 |
|
| 14 |
// Campaign icons choices. |
| 15 |
$buy_now_icon_choices = Merchant_Buy_Now_Icons::get_available_icons(); |
| 16 |
|
| 17 |
if ( ! function_exists( 'merchant_buy_now_get_popup_toggle_field' ) ) { |
| 18 |
/** |
| 19 |
* Return the popup toggle field based on Pro/module availability. |
| 20 |
* |
| 21 |
* - Free only: info notice with upgrade CTA. |
| 22 |
* - Pro installed, popup inactive: info notice with activation link. |
| 23 |
* - Pro + popup active: switcher toggle. |
| 24 |
* |
| 25 |
* @return array<string, mixed> |
| 26 |
*/ |
| 27 |
function merchant_buy_now_get_popup_toggle_field(): array { |
| 28 |
if ( ! defined( 'MERCHANT_PRO_VERSION' ) ) { |
| 29 |
return array( |
| 30 |
'id' => 'show_cart_popup_info', |
| 31 |
'type' => 'info', |
| 32 |
'content' => esc_html__( 'Show the Added to Cart Popup instead of redirecting immediately. This feature requires Merchant Pro.', 'merchant' ), |
| 33 |
); |
| 34 |
} |
| 35 |
|
| 36 |
if ( ! Merchant_Modules::is_module_active( 'added-to-cart-popup' ) ) { |
| 37 |
$activation_url = admin_url( 'admin.php?page=merchant&module=added-to-cart-popup' ); |
| 38 |
|
| 39 |
return array( |
| 40 |
'id' => 'show_cart_popup_info', |
| 41 |
'type' => 'info', |
| 42 |
'content' => sprintf( |
| 43 |
/* translators: %s: module activation link */ |
| 44 |
esc_html__( 'To show a popup before redirecting, activate the %s module first.', 'merchant' ), |
| 45 |
'<a href="' . esc_url( $activation_url ) . '">' . esc_html__( 'Added to Cart Popup', 'merchant' ) . '</a>' |
| 46 |
), |
| 47 |
); |
| 48 |
} |
| 49 |
|
| 50 |
return array( |
| 51 |
'id' => 'show_cart_popup', |
| 52 |
'type' => 'switcher', |
| 53 |
'title' => esc_html__( 'Show Added to Cart Popup', 'merchant' ), |
| 54 |
'desc' => esc_html__( 'Display the Added to Cart Popup before redirecting to checkout.', 'merchant' ), |
| 55 |
'default' => 0, |
| 56 |
); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Campaigns |
| 62 |
*/ |
| 63 |
Merchant_Admin_Options::create( array( |
| 64 |
'module' => 'buy-now', |
| 65 |
'title' => esc_html__( 'Campaigns', 'merchant' ), |
| 66 |
'fields' => array( |
| 67 |
array( |
| 68 |
'id' => 'campaigns', |
| 69 |
'type' => 'flexible_content', |
| 70 |
'sorting' => true, |
| 71 |
'accordion' => true, |
| 72 |
'duplicate' => true, |
| 73 |
'style' => 'buy-now-style default', |
| 74 |
'button_label' => esc_html__( 'Add New Campaign', 'merchant' ), |
| 75 |
'layouts' => array( |
| 76 |
'campaign-details' => array( |
| 77 |
'title' => esc_html__( 'Campaign', 'merchant' ), |
| 78 |
'title-field' => 'offer-title', |
| 79 |
'status-field' => 'campaign_status', |
| 80 |
'fields' => array( |
| 81 |
|
| 82 |
// ── Campaign Meta ───────────────────────────────────── |
| 83 |
array( |
| 84 |
'id' => 'campaign_status', |
| 85 |
'type' => 'select', |
| 86 |
'title' => esc_html__( 'Status', 'merchant' ), |
| 87 |
'options' => array( |
| 88 |
'active' => esc_html__( 'Active', 'merchant' ), |
| 89 |
'inactive' => esc_html__( 'Inactive', 'merchant' ), |
| 90 |
), |
| 91 |
'default' => 'active', |
| 92 |
), |
| 93 |
array( |
| 94 |
'id' => 'offer-title', |
| 95 |
'type' => 'text', |
| 96 |
'title' => esc_html__( 'Campaign name', 'merchant' ), |
| 97 |
'default' => esc_html__( 'Campaign', 'merchant' ), |
| 98 |
), |
| 99 |
|
| 100 |
// ── Product Targeting ───────────────────────────────── |
| 101 |
array( |
| 102 |
'id' => 'rules_to_display', |
| 103 |
'type' => 'select', |
| 104 |
'title' => esc_html__( 'Apply to', 'merchant' ), |
| 105 |
'options' => array( |
| 106 |
'all' => esc_html__( 'All Products', 'merchant' ), |
| 107 |
'products' => esc_html__( 'Specific Products', 'merchant' ), |
| 108 |
'categories' => esc_html__( 'Specific Categories', 'merchant' ), |
| 109 |
'tags' => esc_html__( 'Specific Tags', 'merchant' ), |
| 110 |
'brands' => esc_html__( 'Specific Brands', 'merchant' ), |
| 111 |
), |
| 112 |
'default' => 'all', |
| 113 |
), |
| 114 |
array( |
| 115 |
'id' => 'product_ids', |
| 116 |
'type' => 'products_selector', |
| 117 |
'title' => esc_html__( 'Products', 'merchant' ), |
| 118 |
'multiple' => true, |
| 119 |
'desc' => esc_html__( 'Select products that will show the Buy Now button.', 'merchant' ), |
| 120 |
'condition' => array( 'rules_to_display', '==', 'products' ), |
| 121 |
'allowed_types' => array( 'simple', 'variable', 'variation' ), |
| 122 |
), |
| 123 |
array( |
| 124 |
'id' => 'category_slugs', |
| 125 |
'type' => 'select_ajax', |
| 126 |
'title' => esc_html__( 'Categories', 'merchant' ), |
| 127 |
'source' => 'options', |
| 128 |
'multiple' => true, |
| 129 |
'options' => Merchant_Admin_Options::get_category_select2_choices(), |
| 130 |
'placeholder' => esc_html__( 'Select categories', 'merchant' ), |
| 131 |
'desc' => esc_html__( 'Select product categories that will show the Buy Now button.', 'merchant' ), |
| 132 |
'condition' => array( 'rules_to_display', '==', 'categories' ), |
| 133 |
), |
| 134 |
array( |
| 135 |
'id' => 'tag_slugs', |
| 136 |
'type' => 'select_ajax', |
| 137 |
'title' => esc_html__( 'Tags', 'merchant' ), |
| 138 |
'source' => 'options', |
| 139 |
'multiple' => true, |
| 140 |
'options' => Merchant_Admin_Options::get_tag_select2_choices(), |
| 141 |
'placeholder' => esc_html__( 'Select tags', 'merchant' ), |
| 142 |
'desc' => esc_html__( 'Select product tags that will show the Buy Now button.', 'merchant' ), |
| 143 |
'condition' => array( 'rules_to_display', '==', 'tags' ), |
| 144 |
), |
| 145 |
array( |
| 146 |
'id' => 'brand_slugs', |
| 147 |
'type' => 'select_ajax', |
| 148 |
'title' => esc_html__( 'Brands', 'merchant' ), |
| 149 |
'source' => 'options', |
| 150 |
'multiple' => true, |
| 151 |
'options' => Merchant_Admin_Options::get_brand_select2_choices(), |
| 152 |
'placeholder' => esc_html__( 'Select brands', 'merchant' ), |
| 153 |
'desc' => esc_html__( 'Select product brands that will show the Buy Now button.', 'merchant' ), |
| 154 |
'condition' => array( 'rules_to_display', '==', 'brands' ), |
| 155 |
), |
| 156 |
|
| 157 |
// ── Product Exclusions ──────────────────────────────── |
| 158 |
array( |
| 159 |
'id' => 'exclude_products_toggle', |
| 160 |
'type' => 'switcher', |
| 161 |
'title' => esc_html__( 'Exclude products', 'merchant' ), |
| 162 |
'default' => 0, |
| 163 |
'conditions' => array( |
| 164 |
'relation' => 'AND', |
| 165 |
'terms' => array( |
| 166 |
array( |
| 167 |
'field' => 'rules_to_display', |
| 168 |
'operator' => 'in', |
| 169 |
'value' => array( 'all', 'categories', 'tags', 'brands' ), |
| 170 |
), |
| 171 |
), |
| 172 |
), |
| 173 |
), |
| 174 |
array( |
| 175 |
'id' => 'excluded_products', |
| 176 |
'type' => 'products_selector', |
| 177 |
'title' => esc_html__( 'Excluded Products', 'merchant' ), |
| 178 |
'multiple' => true, |
| 179 |
'desc' => esc_html__( 'Select products to exclude from this campaign.', 'merchant' ), |
| 180 |
'allowed_types' => array( 'simple', 'variable', 'variation' ), |
| 181 |
'conditions' => array( |
| 182 |
'relation' => 'AND', |
| 183 |
'terms' => array( |
| 184 |
array( |
| 185 |
'field' => 'rules_to_display', |
| 186 |
'operator' => 'in', |
| 187 |
'value' => array( 'all', 'categories', 'tags', 'brands' ), |
| 188 |
), |
| 189 |
array( |
| 190 |
'field' => 'exclude_products_toggle', |
| 191 |
'operator' => '===', |
| 192 |
'value' => true, |
| 193 |
), |
| 194 |
), |
| 195 |
), |
| 196 |
), |
| 197 |
array( |
| 198 |
'id' => 'exclude_categories_toggle', |
| 199 |
'type' => 'switcher', |
| 200 |
'title' => esc_html__( 'Exclude categories', 'merchant' ), |
| 201 |
'default' => 0, |
| 202 |
'conditions' => array( |
| 203 |
'relation' => 'AND', |
| 204 |
'terms' => array( |
| 205 |
array( |
| 206 |
'field' => 'rules_to_display', |
| 207 |
'operator' => 'in', |
| 208 |
'value' => array( 'all', 'products', 'tags', 'brands' ), |
| 209 |
), |
| 210 |
), |
| 211 |
), |
| 212 |
), |
| 213 |
array( |
| 214 |
'id' => 'excluded_categories', |
| 215 |
'type' => 'select_ajax', |
| 216 |
'title' => esc_html__( 'Excluded Categories', 'merchant' ), |
| 217 |
'source' => 'options', |
| 218 |
'multiple' => true, |
| 219 |
'options' => Merchant_Admin_Options::get_category_select2_choices(), |
| 220 |
'placeholder' => esc_html__( 'Select categories', 'merchant' ), |
| 221 |
'conditions' => array( |
| 222 |
'relation' => 'AND', |
| 223 |
'terms' => array( |
| 224 |
array( |
| 225 |
'field' => 'rules_to_display', |
| 226 |
'operator' => 'in', |
| 227 |
'value' => array( 'all', 'products', 'tags', 'brands' ), |
| 228 |
), |
| 229 |
array( |
| 230 |
'field' => 'exclude_categories_toggle', |
| 231 |
'operator' => '===', |
| 232 |
'value' => true, |
| 233 |
), |
| 234 |
), |
| 235 |
), |
| 236 |
), |
| 237 |
array( |
| 238 |
'id' => 'exclude_tags_toggle', |
| 239 |
'type' => 'switcher', |
| 240 |
'title' => esc_html__( 'Exclude tags', 'merchant' ), |
| 241 |
'default' => 0, |
| 242 |
'conditions' => array( |
| 243 |
'relation' => 'AND', |
| 244 |
'terms' => array( |
| 245 |
array( |
| 246 |
'field' => 'rules_to_display', |
| 247 |
'operator' => 'in', |
| 248 |
'value' => array( 'all', 'products', 'categories', 'brands' ), |
| 249 |
), |
| 250 |
), |
| 251 |
), |
| 252 |
), |
| 253 |
array( |
| 254 |
'id' => 'excluded_tags', |
| 255 |
'type' => 'select_ajax', |
| 256 |
'title' => esc_html__( 'Excluded Tags', 'merchant' ), |
| 257 |
'source' => 'options', |
| 258 |
'multiple' => true, |
| 259 |
'options' => Merchant_Admin_Options::get_tag_select2_choices(), |
| 260 |
'placeholder' => esc_html__( 'Select tags', 'merchant' ), |
| 261 |
'conditions' => array( |
| 262 |
'relation' => 'AND', |
| 263 |
'terms' => array( |
| 264 |
array( |
| 265 |
'field' => 'rules_to_display', |
| 266 |
'operator' => 'in', |
| 267 |
'value' => array( 'all', 'products', 'categories', 'brands' ), |
| 268 |
), |
| 269 |
array( |
| 270 |
'field' => 'exclude_tags_toggle', |
| 271 |
'operator' => '===', |
| 272 |
'value' => true, |
| 273 |
), |
| 274 |
), |
| 275 |
), |
| 276 |
), |
| 277 |
|
| 278 |
// ── User Conditions ─────────────────────────────────── |
| 279 |
array( |
| 280 |
'id' => 'user_condition', |
| 281 |
'type' => 'select', |
| 282 |
'title' => esc_html__( 'User Condition', 'merchant' ), |
| 283 |
'desc' => esc_html__( 'Choose which users can see the Buy Now button for this campaign.', 'merchant' ), |
| 284 |
'options' => array( |
| 285 |
'all' => esc_html__( 'All Users', 'merchant' ), |
| 286 |
'customers' => esc_html__( 'Selected Users', 'merchant' ), |
| 287 |
'roles' => esc_html__( 'Selected Roles', 'merchant' ), |
| 288 |
), |
| 289 |
'default' => 'all', |
| 290 |
), |
| 291 |
array( |
| 292 |
'id' => 'user_condition_roles', |
| 293 |
'type' => 'select_ajax', |
| 294 |
'title' => esc_html__( 'User Roles', 'merchant' ), |
| 295 |
'desc' => esc_html__( 'This will limit the campaign to users with these roles.', 'merchant' ), |
| 296 |
'source' => 'options', |
| 297 |
'multiple' => true, |
| 298 |
'classes' => array( 'flex-grow' ), |
| 299 |
'options' => Merchant_Admin_Options::get_user_roles_select2_choices(), |
| 300 |
'condition' => array( 'user_condition', '==', 'roles' ), |
| 301 |
), |
| 302 |
array( |
| 303 |
'id' => 'user_condition_users', |
| 304 |
'type' => 'select_ajax', |
| 305 |
'title' => esc_html__( 'Users', 'merchant' ), |
| 306 |
'desc' => esc_html__( 'This will limit the campaign to the selected customers.', 'merchant' ), |
| 307 |
'source' => 'user', |
| 308 |
'multiple' => true, |
| 309 |
'classes' => array( 'flex-grow' ), |
| 310 |
'condition' => array( 'user_condition', '==', 'customers' ), |
| 311 |
), |
| 312 |
array( |
| 313 |
'id' => 'user_exclusion_enabled', |
| 314 |
'type' => 'switcher', |
| 315 |
'title' => esc_html__( 'Exclusion List', 'merchant' ), |
| 316 |
'desc' => esc_html__( 'Exclude specific users or roles from this campaign.', 'merchant' ), |
| 317 |
'default' => 0, |
| 318 |
'conditions' => array( |
| 319 |
'relation' => 'AND', |
| 320 |
'terms' => array( |
| 321 |
array( |
| 322 |
'field' => 'user_condition', |
| 323 |
'operator' => 'in', |
| 324 |
'value' => array( 'all', 'roles' ), |
| 325 |
), |
| 326 |
), |
| 327 |
), |
| 328 |
), |
| 329 |
array( |
| 330 |
'id' => 'exclude_roles', |
| 331 |
'type' => 'select_ajax', |
| 332 |
'title' => esc_html__( 'Exclude Roles', 'merchant' ), |
| 333 |
'desc' => esc_html__( 'Users with these roles will not see the Buy Now button.', 'merchant' ), |
| 334 |
'source' => 'options', |
| 335 |
'multiple' => true, |
| 336 |
'classes' => array( 'flex-grow' ), |
| 337 |
'options' => Merchant_Admin_Options::get_user_roles_select2_choices(), |
| 338 |
'conditions' => array( |
| 339 |
'relation' => 'AND', |
| 340 |
'terms' => array( |
| 341 |
array( |
| 342 |
'field' => 'user_condition', |
| 343 |
'operator' => 'in', |
| 344 |
'value' => array( 'all' ), |
| 345 |
), |
| 346 |
array( |
| 347 |
'field' => 'user_exclusion_enabled', |
| 348 |
'operator' => '===', |
| 349 |
'value' => true, |
| 350 |
), |
| 351 |
), |
| 352 |
), |
| 353 |
), |
| 354 |
array( |
| 355 |
'id' => 'exclude_users', |
| 356 |
'type' => 'select_ajax', |
| 357 |
'title' => esc_html__( 'Exclude Users', 'merchant' ), |
| 358 |
'desc' => esc_html__( 'These users will not see the Buy Now button.', 'merchant' ), |
| 359 |
'source' => 'user', |
| 360 |
'multiple' => true, |
| 361 |
'classes' => array( 'flex-grow' ), |
| 362 |
'conditions' => array( |
| 363 |
'relation' => 'AND', |
| 364 |
'terms' => array( |
| 365 |
array( |
| 366 |
'field' => 'user_condition', |
| 367 |
'operator' => 'in', |
| 368 |
'value' => array( 'all', 'roles' ), |
| 369 |
), |
| 370 |
array( |
| 371 |
'field' => 'user_exclusion_enabled', |
| 372 |
'operator' => '===', |
| 373 |
'value' => true, |
| 374 |
), |
| 375 |
), |
| 376 |
), |
| 377 |
), |
| 378 |
|
| 379 |
// ── Button Behavior ─────────────────────────────────── |
| 380 |
array( |
| 381 |
'id' => 'cart_action', |
| 382 |
'type' => 'select', |
| 383 |
'title' => esc_html__( 'Cart Action', 'merchant' ), |
| 384 |
'desc' => esc_html__( 'What to do with existing cart items when Buy Now is clicked.', 'merchant' ), |
| 385 |
'options' => array( |
| 386 |
'keep' => esc_html__( 'Keep existing cart items', 'merchant' ), |
| 387 |
'clear' => esc_html__( 'Clear cart before adding product', 'merchant' ), |
| 388 |
), |
| 389 |
'default' => 'keep', |
| 390 |
), |
| 391 |
array( |
| 392 |
'id' => 'redirect_to', |
| 393 |
'type' => 'select', |
| 394 |
'title' => esc_html__( 'Redirect After Purchase', 'merchant' ), |
| 395 |
'options' => array( |
| 396 |
'checkout' => esc_html__( 'Checkout page', 'merchant' ), |
| 397 |
'custom_url' => esc_html__( 'Custom URL', 'merchant' ), |
| 398 |
), |
| 399 |
'default' => 'checkout', |
| 400 |
), |
| 401 |
array( |
| 402 |
'id' => 'custom_redirect_url', |
| 403 |
'type' => 'text', |
| 404 |
'title' => esc_html__( 'Custom Redirect URL', 'merchant' ), |
| 405 |
'desc' => esc_html__( 'Enter the full URL to redirect to after adding to cart.', 'merchant' ), |
| 406 |
'default' => '', |
| 407 |
'condition' => array( 'redirect_to', '==', 'custom_url' ), |
| 408 |
), |
| 409 |
|
| 410 |
// ── Button Design ───────────────────────────────────── |
| 411 |
array( |
| 412 |
'id' => 'button_text', |
| 413 |
'type' => 'text', |
| 414 |
'title' => esc_html__( 'Button text', 'merchant' ), |
| 415 |
'default' => esc_html__( 'Buy Now', 'merchant' ), |
| 416 |
), |
| 417 |
array( |
| 418 |
'id' => 'button_icon', |
| 419 |
'type' => 'select', |
| 420 |
'title' => esc_html__( 'Button icon', 'merchant' ), |
| 421 |
'options' => $buy_now_icon_choices, |
| 422 |
'default' => 'none', |
| 423 |
), |
| 424 |
array( |
| 425 |
'id' => 'button_icon_position', |
| 426 |
'type' => 'select', |
| 427 |
'title' => esc_html__( 'Icon position', 'merchant' ), |
| 428 |
'options' => array( |
| 429 |
'before' => esc_html__( 'Before text', 'merchant' ), |
| 430 |
'after' => esc_html__( 'After text', 'merchant' ), |
| 431 |
), |
| 432 |
'default' => 'before', |
| 433 |
'conditions' => array( |
| 434 |
'relation' => 'AND', |
| 435 |
'terms' => array( |
| 436 |
array( |
| 437 |
'field' => 'button_icon', |
| 438 |
'operator' => 'in', |
| 439 |
'value' => array( 'cart', 'lightning', 'arrow', 'custom' ), |
| 440 |
), |
| 441 |
), |
| 442 |
), |
| 443 |
), |
| 444 |
array( |
| 445 |
'id' => 'button_icon_svg', |
| 446 |
'type' => 'textarea', |
| 447 |
'title' => esc_html__( 'Custom SVG markup', 'merchant' ), |
| 448 |
'desc' => esc_html__( 'Paste your custom SVG icon markup here.', 'merchant' ), |
| 449 |
'default' => '', |
| 450 |
'condition' => array( 'button_icon', '==', 'custom' ), |
| 451 |
'sanitize' => 'merchant_sanitize_svg', |
| 452 |
), |
| 453 |
|
| 454 |
// ── Added to Cart Popup Integration ────────────────── |
| 455 |
merchant_buy_now_get_popup_toggle_field(), |
| 456 |
|
| 457 |
), |
| 458 |
), |
| 459 |
), |
| 460 |
), |
| 461 |
), |
| 462 |
) ); |
| 463 |
|
| 464 |
/** |
| 465 |
* Button Style (Global) |
| 466 |
*/ |
| 467 |
Merchant_Admin_Options::create( array( |
| 468 |
'title' => esc_html__( 'Button Style', 'merchant' ), |
| 469 |
'module' => 'buy-now', |
| 470 |
'fields' => array( |
| 471 |
|
| 472 |
// Customize The Button or Inherit from Themes. |
| 473 |
array( |
| 474 |
'id' => 'customize-button', |
| 475 |
'type' => 'switcher', |
| 476 |
'title' => esc_html__( 'Customize Button', 'merchant' ), |
| 477 |
'default' => 1, |
| 478 |
), |
| 479 |
|
| 480 |
array( |
| 481 |
'id' => 'text-color', |
| 482 |
'type' => 'color', |
| 483 |
'title' => esc_html__( 'Button text color', 'merchant' ), |
| 484 |
'default' => '#ffffff', |
| 485 |
'condition' => array( 'customize-button', '==', '1' ), |
| 486 |
), |
| 487 |
|
| 488 |
array( |
| 489 |
'id' => 'text-hover-color', |
| 490 |
'type' => 'color', |
| 491 |
'title' => esc_html__( 'Button text color hover', 'merchant' ), |
| 492 |
'default' => '#ffffff', |
| 493 |
'condition' => array( 'customize-button', '==', '1' ), |
| 494 |
), |
| 495 |
|
| 496 |
array( |
| 497 |
'id' => 'border-color', |
| 498 |
'type' => 'color', |
| 499 |
'title' => esc_html__( 'Button border color', 'merchant' ), |
| 500 |
'default' => '#212121', |
| 501 |
'condition' => array( 'customize-button', '==', '1' ), |
| 502 |
), |
| 503 |
|
| 504 |
array( |
| 505 |
'id' => 'border-hover-color', |
| 506 |
'type' => 'color', |
| 507 |
'title' => esc_html__( 'Button border color hover', 'merchant' ), |
| 508 |
'default' => '#414141', |
| 509 |
'condition' => array( 'customize-button', '==', '1' ), |
| 510 |
), |
| 511 |
|
| 512 |
array( |
| 513 |
'id' => 'background-color', |
| 514 |
'type' => 'color', |
| 515 |
'title' => esc_html__( 'Button background color', 'merchant' ), |
| 516 |
'default' => '#212121', |
| 517 |
'condition' => array( 'customize-button', '==', '1' ), |
| 518 |
), |
| 519 |
|
| 520 |
array( |
| 521 |
'id' => 'background-hover-color', |
| 522 |
'type' => 'color', |
| 523 |
'title' => esc_html__( 'Button background color hover', 'merchant' ), |
| 524 |
'default' => '#414141', |
| 525 |
'condition' => array( 'customize-button', '==', '1' ), |
| 526 |
), |
| 527 |
|
| 528 |
array( |
| 529 |
'id' => 'button-size', |
| 530 |
'type' => 'select', |
| 531 |
'title' => esc_html__( 'Button size', 'merchant' ), |
| 532 |
'options' => array( |
| 533 |
'small' => esc_html__( 'Small', 'merchant' ), |
| 534 |
'medium' => esc_html__( 'Medium', 'merchant' ), |
| 535 |
'large' => esc_html__( 'Large', 'merchant' ), |
| 536 |
'custom' => esc_html__( 'Custom', 'merchant' ), |
| 537 |
), |
| 538 |
'default' => 'medium', |
| 539 |
'condition' => array( 'customize-button', '==', '1' ), |
| 540 |
), |
| 541 |
|
| 542 |
array( |
| 543 |
'id' => 'font-size', |
| 544 |
'type' => 'range', |
| 545 |
'title' => esc_html__( 'Font size', 'merchant' ), |
| 546 |
'min' => 1, |
| 547 |
'max' => 100, |
| 548 |
'step' => 1, |
| 549 |
'default' => 16, |
| 550 |
'unit' => 'px', |
| 551 |
'condition' => array( 'customize-button', '==', '1' ), |
| 552 |
), |
| 553 |
|
| 554 |
array( |
| 555 |
'id' => 'margin-top', |
| 556 |
'type' => 'range', |
| 557 |
'title' => esc_html__( 'Margin top', 'merchant' ), |
| 558 |
'min' => 0, |
| 559 |
'max' => 100, |
| 560 |
'step' => 1, |
| 561 |
'default' => 10, |
| 562 |
'unit' => 'px', |
| 563 |
'conditions' => array( |
| 564 |
'terms' => array( |
| 565 |
array( |
| 566 |
'field' => 'customize-button', |
| 567 |
'operator' => '===', |
| 568 |
'value' => true, |
| 569 |
), |
| 570 |
), |
| 571 |
), |
| 572 |
), |
| 573 |
|
| 574 |
array( |
| 575 |
'id' => 'margin-bottom', |
| 576 |
'type' => 'range', |
| 577 |
'title' => esc_html__( 'Margin bottom', 'merchant' ), |
| 578 |
'min' => 0, |
| 579 |
'max' => 100, |
| 580 |
'step' => 1, |
| 581 |
'default' => 10, |
| 582 |
'unit' => 'px', |
| 583 |
'conditions' => array( |
| 584 |
'terms' => array( |
| 585 |
array( |
| 586 |
'field' => 'customize-button', |
| 587 |
'operator' => '===', |
| 588 |
'value' => true, |
| 589 |
), |
| 590 |
), |
| 591 |
), |
| 592 |
), |
| 593 |
|
| 594 |
array( |
| 595 |
'id' => 'padding_top_bottom', |
| 596 |
'type' => 'range', |
| 597 |
'title' => esc_html__( 'Padding Top/Bottom', 'merchant' ), |
| 598 |
'min' => 0, |
| 599 |
'max' => 100, |
| 600 |
'step' => 1, |
| 601 |
'default' => 12, |
| 602 |
'unit' => 'px', |
| 603 |
'conditions' => array( |
| 604 |
'terms' => array( |
| 605 |
array( |
| 606 |
'field' => 'customize-button', |
| 607 |
'operator' => '===', |
| 608 |
'value' => true, |
| 609 |
), |
| 610 |
), |
| 611 |
), |
| 612 |
), |
| 613 |
|
| 614 |
array( |
| 615 |
'id' => 'padding_left_right', |
| 616 |
'type' => 'range', |
| 617 |
'title' => esc_html__( 'Padding Left/Right', 'merchant' ), |
| 618 |
'min' => 0, |
| 619 |
'max' => 100, |
| 620 |
'step' => 1, |
| 621 |
'default' => 24, |
| 622 |
'unit' => 'px', |
| 623 |
'conditions' => array( |
| 624 |
'terms' => array( |
| 625 |
array( |
| 626 |
'field' => 'customize-button', |
| 627 |
'operator' => '===', |
| 628 |
'value' => true, |
| 629 |
), |
| 630 |
), |
| 631 |
), |
| 632 |
), |
| 633 |
|
| 634 |
array( |
| 635 |
'id' => 'border-radius', |
| 636 |
'type' => 'range', |
| 637 |
'title' => esc_html__( 'Border radius', 'merchant' ), |
| 638 |
'min' => 0, |
| 639 |
'max' => 9999, |
| 640 |
'step' => 1, |
| 641 |
'unit' => 'px', |
| 642 |
'default' => 0, |
| 643 |
'condition' => array( 'customize-button', '==', '1' ), |
| 644 |
), |
| 645 |
|
| 646 |
), |
| 647 |
) ); |
| 648 |
|
| 649 |
/** |
| 650 |
* Display Settings (Global) |
| 651 |
*/ |
| 652 |
Merchant_Admin_Options::create( array( |
| 653 |
'module' => 'buy-now', |
| 654 |
'title' => esc_html__( 'Display Settings', 'merchant' ), |
| 655 |
'fields' => array( |
| 656 |
|
| 657 |
array( |
| 658 |
'id' => 'display-archive', |
| 659 |
'type' => 'checkbox', |
| 660 |
'label' => __( 'Show on product archive', 'merchant' ), |
| 661 |
'default' => 1, |
| 662 |
), |
| 663 |
array( |
| 664 |
'id' => 'display-product', |
| 665 |
'type' => 'checkbox', |
| 666 |
'label' => __( 'Show on single product page', 'merchant' ), |
| 667 |
'default' => 1, |
| 668 |
), |
| 669 |
array( |
| 670 |
'id' => 'display-upsell-related', |
| 671 |
'type' => 'checkbox', |
| 672 |
'label' => __( 'Show on upsell and related products', 'merchant' ), |
| 673 |
'default' => 1, |
| 674 |
), |
| 675 |
|
| 676 |
// Loading position/priority on shop archive. |
| 677 |
array( |
| 678 |
'id' => 'hook-order-shop-archive', |
| 679 |
'type' => 'hook_select', |
| 680 |
'title' => __( 'Loading position and priority on shop archive', 'merchant' ), |
| 681 |
'options' => array( |
| 682 |
'woocommerce_before_shop_loop_item' => __( 'Before shop loop item', 'merchant' ), |
| 683 |
'woocommerce_before_shop_loop_item_title' => __( 'Before shop loop item title', 'merchant' ), |
| 684 |
'woocommerce_shop_loop_item_title' => __( 'Shop loop item title', 'merchant' ), |
| 685 |
'woocommerce_after_shop_loop_item_title' => __( 'After shop loop item title', 'merchant' ), |
| 686 |
'woocommerce_after_shop_loop_item' => __( 'After shop loop item', 'merchant' ), |
| 687 |
), |
| 688 |
'min' => -999, |
| 689 |
'max' => 999, |
| 690 |
'step' => 1, |
| 691 |
'unit' => '', |
| 692 |
'order' => true, |
| 693 |
'default' => array( |
| 694 |
'hook_name' => 'woocommerce_after_shop_loop_item', |
| 695 |
'hook_priority' => 10, |
| 696 |
), |
| 697 |
), |
| 698 |
array( |
| 699 |
'id' => 'hook-order-shop-archive_info', |
| 700 |
'type' => 'info', |
| 701 |
'content' => esc_html__( 'This is a developer level feature. The buy now button module is "hooked" into a specific location on the shop archive pages. Themes and other plugins might also add additional elements to the same location. By modifying the loading postiion and priority, you have the ability to customize the placement of this element on that particular location. A lower number = a higher priority, so the module will appear higher on the page.', 'merchant' ), |
| 702 |
), |
| 703 |
|
| 704 |
// Loading position/priority on single product. |
| 705 |
array( |
| 706 |
'id' => 'hook-order-single-product', |
| 707 |
'type' => 'hook_select', |
| 708 |
'title' => __( 'Loading position and priority on single product', 'merchant' ), |
| 709 |
'options' => array( |
| 710 |
'woocommerce_before_add_to_cart_button' => __( 'Before add to cart button', 'merchant' ), |
| 711 |
'woocommerce_after_add_to_cart_button' => __( 'After add to cart button', 'merchant' ), |
| 712 |
'woocommerce_before_add_to_cart_quantity' => __( 'Before add to cart quantity', 'merchant' ), |
| 713 |
'woocommerce_after_add_to_cart_quantity' => __( 'After add to cart quantity', 'merchant' ), |
| 714 |
), |
| 715 |
'min' => -999, |
| 716 |
'max' => 999, |
| 717 |
'step' => 1, |
| 718 |
'unit' => '', |
| 719 |
'order' => true, |
| 720 |
'default' => array( |
| 721 |
'hook_name' => 'woocommerce_after_add_to_cart_button', |
| 722 |
'hook_priority' => 10, |
| 723 |
), |
| 724 |
), |
| 725 |
array( |
| 726 |
'id' => 'hook-order-single-product_info', |
| 727 |
'type' => 'info', |
| 728 |
'content' => esc_html__( 'This is a developer level feature. The buy now button module is "hooked" into a specific location on the single product pages. Themes and other plugins might also add additional elements to the same location. By modifying the loading postiion and priority, you have the ability to customize the placement of this element on that particular location. A lower number = a higher priority, so the module will appear higher on the page.', 'merchant' ), |
| 729 |
), |
| 730 |
), |
| 731 |
) ); |