| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Stock Scarcity Options. |
| 5 |
* |
| 6 |
* @package Merchant |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; // Exit if accessed directly |
| 11 |
} |
| 12 |
|
| 13 |
|
| 14 |
// Settings |
| 15 |
Merchant_Admin_Options::create( array( |
| 16 |
'module' => Merchant_Stock_Scarcity::MODULE_ID, |
| 17 |
'title' => esc_html__( 'Settings', 'merchant' ), |
| 18 |
'fields' => array( |
| 19 |
array( |
| 20 |
'id' => 'single_product_placement', |
| 21 |
'type' => 'select', |
| 22 |
'title' => esc_html__( 'Placement on product page', 'merchant' ), |
| 23 |
'options' => array( |
| 24 |
'after-cart-form' => esc_html__( 'After add to cart form', 'merchant' ), |
| 25 |
'before-cart-form' => esc_html__( 'Before add to cart form', 'merchant' ), |
| 26 |
), |
| 27 |
'default' => 'after-cart-form', |
| 28 |
), |
| 29 |
array( |
| 30 |
'id' => 'min_inventory', |
| 31 |
'type' => 'number', |
| 32 |
'title' => esc_html__( 'Show urgency box when variant inventory is below', 'merchant' ), |
| 33 |
'default' => 50, |
| 34 |
), |
| 35 |
|
| 36 |
), |
| 37 |
) ); |
| 38 |
|
| 39 |
|
| 40 |
// Text Formatting Settings |
| 41 |
Merchant_Admin_Options::create( array( |
| 42 |
'title' => esc_html__( 'Text Formatting Settings', 'merchant' ), |
| 43 |
'module' => Merchant_Stock_Scarcity::MODULE_ID, |
| 44 |
'fields' => array( |
| 45 |
|
| 46 |
array( |
| 47 |
'id' => 'low_inventory_text', |
| 48 |
'type' => 'text', |
| 49 |
'title' => esc_html__( 'Text when inventory is low', 'merchant' ), |
| 50 |
'default' => esc_html__( 'Hurry! Only {stock} unit left in stock!', 'merchant' ), |
| 51 |
), |
| 52 |
|
| 53 |
array( |
| 54 |
'id' => 'low_inventory_text_plural', |
| 55 |
'type' => 'text', |
| 56 |
'title' => esc_html__( 'Text when inventory is low (plural)', 'merchant' ), |
| 57 |
'default' => esc_html__( 'Hurry! Only {stock} units left in stock!', 'merchant' ), |
| 58 |
), |
| 59 |
|
| 60 |
array( |
| 61 |
'id' => 'low_inventory_text_simple', |
| 62 |
'type' => 'text', |
| 63 |
'title' => esc_html__( 'Text when inventory is low (simple - used for product variation)', 'merchant' ), |
| 64 |
'default' => esc_html__( 'Hurry, low stock.', 'merchant' ), |
| 65 |
), |
| 66 |
), |
| 67 |
) ); |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
// Style |
| 72 |
Merchant_Admin_Options::create( array( |
| 73 |
'module' => Merchant_Stock_Scarcity::MODULE_ID, |
| 74 |
'title' => esc_html__( 'Style', 'merchant' ), |
| 75 |
'fields' => array( |
| 76 |
|
| 77 |
array( |
| 78 |
'id' => 'gradient_start', |
| 79 |
'type' => 'color', |
| 80 |
'title' => esc_html__( 'Progress bar gradient start', 'merchant' ), |
| 81 |
'default' => '#ffc108', |
| 82 |
), |
| 83 |
|
| 84 |
array( |
| 85 |
'id' => 'gradient_end', |
| 86 |
'type' => 'color', |
| 87 |
'title' => esc_html__( 'Progress bar gradient end', 'merchant' ), |
| 88 |
'default' => '#d61313', |
| 89 |
), |
| 90 |
|
| 91 |
array( |
| 92 |
'id' => 'progress_bar_bg', |
| 93 |
'type' => 'color', |
| 94 |
'title' => esc_html__( 'Progress bar background color', 'merchant' ), |
| 95 |
'default' => '#e1e1e1', |
| 96 |
), |
| 97 |
|
| 98 |
array( |
| 99 |
'id' => 'text_font_weight', |
| 100 |
'type' => 'select', |
| 101 |
'title' => esc_html__( 'Text font weight', 'merchant' ), |
| 102 |
'options' => array( |
| 103 |
'lighter' => esc_html__( 'Light', 'merchant' ), |
| 104 |
'normal' => esc_html__( 'Normal', 'merchant' ), |
| 105 |
'bold' => esc_html__( 'Bold', 'merchant' ), |
| 106 |
), |
| 107 |
'default' => 'normal', |
| 108 |
), |
| 109 |
|
| 110 |
array( |
| 111 |
'id' => 'text_font_size', |
| 112 |
'type' => 'range', |
| 113 |
'title' => esc_html__( 'Text font size', 'merchant' ), |
| 114 |
'min' => 0, |
| 115 |
'max' => 100, |
| 116 |
'step' => 1, |
| 117 |
'unit' => 'px', |
| 118 |
'default' => 16, |
| 119 |
), |
| 120 |
|
| 121 |
array( |
| 122 |
'id' => 'text_text_color', |
| 123 |
'type' => 'color', |
| 124 |
'title' => esc_html__( 'Text text color', 'merchant' ), |
| 125 |
'default' => '#212121', |
| 126 |
), |
| 127 |
|
| 128 |
), |
| 129 |
) ); |
| 130 |
|
| 131 |
// Shortcode |
| 132 |
$merchant_module_id = Merchant_Stock_Scarcity::MODULE_ID; |
| 133 |
Merchant_Admin_Options::create( array( |
| 134 |
'module' => $merchant_module_id, |
| 135 |
'title' => esc_html__( 'Use shortcode', 'merchant' ), |
| 136 |
'fields' => array( |
| 137 |
array( |
| 138 |
'id' => 'use_shortcode', |
| 139 |
'type' => 'switcher', |
| 140 |
'title' => __( 'Use shortcode', 'merchant' ), |
| 141 |
'default' => 0, |
| 142 |
'desc' => 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.', |
| 143 |
'merchant' ), |
| 144 |
), |
| 145 |
array( |
| 146 |
'id' => 'shortcode_text', |
| 147 |
'type' => 'text_readonly', |
| 148 |
'title' => esc_html__( 'Shortcode text', 'merchant' ), |
| 149 |
'default' => '[merchant_module_' . str_replace( '-', '_', $merchant_module_id ) . ']', |
| 150 |
'condition' => array( 'use_shortcode', '==', '1' ), |
| 151 |
), |
| 152 |
), |
| 153 |
) ); |