| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Free Gifts 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 |
'title' => esc_html__( 'Floating Gift Widget', 'merchant' ), |
| 15 |
'module' => Merchant_Free_Gifts::MODULE_ID, |
| 16 |
'fields' => array( |
| 17 |
array( |
| 18 |
'id' => 'offers', |
| 19 |
'type' => 'flexible_content', |
| 20 |
'button_label' => esc_html__( 'Add New Offer', 'merchant' ), |
| 21 |
'style' => Merchant_Free_Gifts::MODULE_ID . '-style default', |
| 22 |
'sorting' => true, |
| 23 |
'accordion' => true, |
| 24 |
'layouts' => array( |
| 25 |
'spending' => array( |
| 26 |
'title' => esc_html__( 'Spending Based', 'merchant' ), |
| 27 |
'title-field' => 'offer-title', // text field ID to use as title for the layout |
| 28 |
'fields' => array( |
| 29 |
array( |
| 30 |
'id' => 'offer-title', |
| 31 |
'type' => 'text', |
| 32 |
'title' => esc_html__( 'Offer name', 'merchant' ), |
| 33 |
'default' => esc_html__( 'Free Gift Campaign', 'merchant' ), |
| 34 |
), |
| 35 |
array( |
| 36 |
'id' => 'rules_to_apply', |
| 37 |
'type' => 'select', |
| 38 |
'title' => esc_html__( 'Products that can be purchased to claim the gift', 'merchant' ), |
| 39 |
'options' => array( |
| 40 |
'all' => esc_html__( 'Any product', 'merchant' ), |
| 41 |
'product' => esc_html__( 'Specific product', 'merchant' ), |
| 42 |
'categories' => esc_html__( 'Product categories', 'merchant' ), |
| 43 |
), |
| 44 |
'default' => 'all', |
| 45 |
), |
| 46 |
array( |
| 47 |
'id' => 'category_slugs', |
| 48 |
'type' => 'select_ajax', |
| 49 |
'source' => 'options', |
| 50 |
'multiple' => true, |
| 51 |
'options' => Merchant_Admin_Options::get_category_select2_choices(), |
| 52 |
'placeholder' => esc_html__( 'Select categories', 'merchant' ), |
| 53 |
'desc' => esc_html__( 'Select the product categories that the spending goal will apply to.', 'merchant' ), |
| 54 |
'condition' => array( 'rules_to_apply', '==', 'categories' ), |
| 55 |
), |
| 56 |
array( |
| 57 |
'id' => 'product_to_purchase', |
| 58 |
'type' => 'products_selector', |
| 59 |
'multiple' => false, |
| 60 |
'desc' => esc_html__( 'Select the product that the spending goal will apply to.', 'merchant' ), |
| 61 |
'condition' => array( 'rules_to_apply', '==', 'product' ), |
| 62 |
'allowed_types' => array( 'simple', 'variable' ), |
| 63 |
), |
| 64 |
'amount' => array( |
| 65 |
'id' => 'amount', |
| 66 |
'title' => esc_html__( 'Spending goal', 'merchant' ), |
| 67 |
'type' => 'number', |
| 68 |
'append' => function_exists( 'get_woocommerce_currency_symbol' ) ? get_woocommerce_currency() : esc_html__( 'USD', 'merchant' ), |
| 69 |
'default' => 100, |
| 70 |
), |
| 71 |
array( |
| 72 |
'id' => 'product', |
| 73 |
'type' => 'products_selector', |
| 74 |
'title' => esc_html__( 'Product rewarded as a gift', 'merchant' ), |
| 75 |
'multiple' => false, |
| 76 |
'allowed_types' => array( 'simple', 'variable', 'variation' ), |
| 77 |
), |
| 78 |
|
| 79 |
array( |
| 80 |
'id' => 'spending_goal_target', |
| 81 |
'type' => 'content', |
| 82 |
'title' => esc_html__( 'Spending goal target', 'merchant' ), |
| 83 |
'content' => '', |
| 84 |
'desc' => esc_html__( 'Configure the text for the gift offer across three phases. Personalize the text at each phase to maximize conversions.', 'merchant' ), |
| 85 |
), |
| 86 |
|
| 87 |
array( |
| 88 |
'id' => 'spending_text_0', |
| 89 |
'type' => 'text', |
| 90 |
'title' => esc_html__( 'At 0%', 'merchant' ), |
| 91 |
'default' => sprintf( |
| 92 |
/* Translators: 1. goal amount */ |
| 93 |
esc_html__( 'Spend %1$s on any product to receive this gift!', 'merchant' ), |
| 94 |
'{goalAmount}' // existing one is {amount} |
| 95 |
), |
| 96 |
), |
| 97 |
|
| 98 |
array( |
| 99 |
'id' => 'spending_text_1_to_99', |
| 100 |
'type' => 'text', |
| 101 |
'title' => esc_html__( 'Between 1 - 99%', 'merchant' ), |
| 102 |
'default' => sprintf( |
| 103 |
/* Translators: 1. more amount */ |
| 104 |
esc_html__( 'Spend %1$s on any product to receive this gift!', 'merchant' ), |
| 105 |
'{amountMore}' |
| 106 |
), |
| 107 |
), |
| 108 |
|
| 109 |
array( |
| 110 |
'id' => 'spending_text_100', |
| 111 |
'type' => 'text', |
| 112 |
'title' => esc_html__( 'At 100%', 'merchant' ), |
| 113 |
'default' => esc_html__( 'Congratulations! You are eligible to receive a free gift.', 'merchant' ), |
| 114 |
), |
| 115 |
), |
| 116 |
), |
| 117 |
'coupon' => array( |
| 118 |
'title' => esc_html__( 'Coupon Based', 'merchant' ), |
| 119 |
'title-field' => 'offer-title', // text field ID to use as title for the layout |
| 120 |
'fields' => array( |
| 121 |
array( |
| 122 |
'id' => 'offer-title', |
| 123 |
'type' => 'text', |
| 124 |
'title' => esc_html__( 'Offer name', 'merchant' ), |
| 125 |
'default' => esc_html__( 'Campaign', 'merchant' ), |
| 126 |
), |
| 127 |
array( |
| 128 |
'id' => 'product', |
| 129 |
'type' => 'products_selector', |
| 130 |
'title' => esc_html__( 'Product', 'merchant' ), |
| 131 |
'multiple' => false, |
| 132 |
'desc' => esc_html__( 'Select the product that the spending goal will apply to.', 'merchant' ), |
| 133 |
'allowed_types' => array( 'simple', 'variable', 'variation' ), |
| 134 |
), |
| 135 |
'coupon' => array( |
| 136 |
'id' => 'coupon', |
| 137 |
'title' => esc_html__( 'Use coupon to receive this product for free', 'merchant' ), |
| 138 |
'type' => 'wc_coupons', |
| 139 |
), |
| 140 |
), |
| 141 |
), |
| 142 |
), |
| 143 |
'default' => array( |
| 144 |
array( |
| 145 |
'layout' => 'spending', |
| 146 |
'min_quantity' => 2, |
| 147 |
'discount' => 10, |
| 148 |
'discount_type' => 'percentage_discount', |
| 149 |
), |
| 150 |
), |
| 151 |
), |
| 152 |
), |
| 153 |
) ); |
| 154 |
|
| 155 |
// Settings |
| 156 |
Merchant_Admin_Options::create( array( |
| 157 |
'module' => Merchant_Free_Gifts::MODULE_ID, |
| 158 |
'title' => esc_html__( 'Cart Settings', 'merchant' ), |
| 159 |
'fields' => array( |
| 160 |
array( |
| 161 |
'id' => 'total_type', |
| 162 |
'type' => 'select', |
| 163 |
'title' => esc_html__( 'Gift based on spending type', 'merchant' ), |
| 164 |
'desc' => esc_html__( 'Select whether the spending goal for receiving a gift should be based on the ‘Cart Subtotal’ or the ‘Cart Total.’ The ‘Cart Subtotal’ reflects the total before any additional discounts are applied, whereas the ‘Cart Total’ includes all discounts and additional charges.', |
| 165 |
'merchant' ), |
| 166 |
'options' => array( |
| 167 |
'subtotal' => esc_html__( 'Cart subtotal', 'merchant' ), |
| 168 |
'total' => esc_html__( 'Cart total', 'merchant' ), |
| 169 |
), |
| 170 |
'default' => 'subtotal', |
| 171 |
), |
| 172 |
|
| 173 |
array( |
| 174 |
'id' => 'free_text', |
| 175 |
'type' => 'text', |
| 176 |
'title' => esc_html__( 'Gift price label', 'merchant' ), |
| 177 |
'default' => esc_html__( 'Free', 'merchant' ), |
| 178 |
), |
| 179 |
|
| 180 |
array( |
| 181 |
'id' => 'cart_title_text', |
| 182 |
'type' => 'text', |
| 183 |
'title' => esc_html__( 'Cart item title text', 'merchant' ), |
| 184 |
'default' => esc_html__( 'Free Gift', 'merchant' ), |
| 185 |
'desc' => esc_html__( 'This is displayed on the cart page.', 'merchant' ), |
| 186 |
), |
| 187 |
|
| 188 |
array( |
| 189 |
'id' => 'cart_description_text', |
| 190 |
'type' => 'text', |
| 191 |
'title' => esc_html__( 'Cart item description text', 'merchant' ), |
| 192 |
'default' => esc_html__( 'This item was added as a free gift', 'merchant' ), |
| 193 |
'desc' => esc_html__( 'This is displayed on the cart page.', 'merchant' ), |
| 194 |
), |
| 195 |
), |
| 196 |
) ); |
| 197 |
|
| 198 |
// Gift Widget Settings |
| 199 |
Merchant_Admin_Options::create( array( |
| 200 |
'title' => esc_html__( 'Gift Widget', 'merchant' ), |
| 201 |
'module' => Merchant_Free_Gifts::MODULE_ID, |
| 202 |
'fields' => array( |
| 203 |
array( |
| 204 |
'id' => 'icon', |
| 205 |
'type' => 'choices', |
| 206 |
'title' => esc_html__( 'Widget icon', 'merchant' ), |
| 207 |
'options' => array( |
| 208 |
'gifts-icon-1' => MERCHANT_URI . 'assets/images/icons/free-gifts/icon-1.svg', |
| 209 |
'gifts-icon-2' => MERCHANT_URI . 'assets/images/icons/free-gifts/icon-2.svg', |
| 210 |
'gifts-icon-3' => MERCHANT_URI . 'assets/images/icons/free-gifts/icon-3.svg', |
| 211 |
'gifts-icon-4' => MERCHANT_URI . 'assets/images/icons/free-gifts/icon-4.svg', |
| 212 |
'gifts-icon-5' => MERCHANT_URI . 'assets/images/icons/free-gifts/icon-5.svg', |
| 213 |
), |
| 214 |
'default' => 'gifts-icon-1', |
| 215 |
), |
| 216 |
|
| 217 |
array( |
| 218 |
'id' => 'position', |
| 219 |
'type' => 'select', |
| 220 |
'title' => esc_html__( 'Position', 'merchant' ), |
| 221 |
'options' => array( |
| 222 |
'top_right' => esc_html__( 'Top Right', 'merchant' ), |
| 223 |
'top_left' => esc_html__( 'Top Left', 'merchant' ), |
| 224 |
'bottom_right' => esc_html__( 'Bottom Right', 'merchant' ), |
| 225 |
'bottom_left' => esc_html__( 'Bottom Left', 'merchant' ), |
| 226 |
), |
| 227 |
'default' => 'top_right', |
| 228 |
), |
| 229 |
|
| 230 |
array( |
| 231 |
'id' => 'distance', |
| 232 |
'type' => 'range', |
| 233 |
'title' => esc_html__( 'Distance', 'merchant' ), |
| 234 |
'min' => 0, |
| 235 |
'max' => 999, |
| 236 |
'step' => 1, |
| 237 |
'unit' => 'px', |
| 238 |
'default' => 150, |
| 239 |
), |
| 240 |
|
| 241 |
array( |
| 242 |
'id' => 'display_homepage', |
| 243 |
'type' => 'checkbox', |
| 244 |
'title' => esc_html__( 'Show on pages', 'merchant' ), |
| 245 |
'label' => esc_html__( 'Homepage', 'merchant' ), |
| 246 |
'default' => 1, |
| 247 |
), |
| 248 |
|
| 249 |
array( |
| 250 |
'id' => 'display_shop', |
| 251 |
'type' => 'checkbox', |
| 252 |
'label' => esc_html__( 'Shop page', 'merchant' ), |
| 253 |
'default' => 1, |
| 254 |
), |
| 255 |
|
| 256 |
array( |
| 257 |
'id' => 'display_product', |
| 258 |
'type' => 'checkbox', |
| 259 |
'label' => esc_html__( 'Product page', 'merchant' ), |
| 260 |
'default' => 1, |
| 261 |
), |
| 262 |
|
| 263 |
array( |
| 264 |
'id' => 'display_cart', |
| 265 |
'type' => 'checkbox', |
| 266 |
'label' => esc_html__( 'Cart page', 'merchant' ), |
| 267 |
'default' => 1, |
| 268 |
), |
| 269 |
), |
| 270 |
) ); |
| 271 |
|
| 272 |
// Style Settings |
| 273 |
Merchant_Admin_Options::create( array( |
| 274 |
'module' => Merchant_Free_Gifts::MODULE_ID, |
| 275 |
'title' => esc_html__( 'Look and Feel', 'merchant' ), |
| 276 |
'fields' => array( |
| 277 |
|
| 278 |
array( |
| 279 |
'id' => 'count_bg_color', |
| 280 |
'type' => 'color', |
| 281 |
'title' => esc_html__( 'Count background color', 'merchant' ), |
| 282 |
'default' => '#000', |
| 283 |
), |
| 284 |
|
| 285 |
array( |
| 286 |
'id' => 'count_text_color', |
| 287 |
'type' => 'color', |
| 288 |
'title' => esc_html__( 'Count text color', 'merchant' ), |
| 289 |
'default' => '#fff', |
| 290 |
), |
| 291 |
|
| 292 |
array( |
| 293 |
'id' => 'button_bg_color', |
| 294 |
'type' => 'color', |
| 295 |
'title' => esc_html__( 'Gift button background color', 'merchant' ), |
| 296 |
'default' => '#362e94', |
| 297 |
), |
| 298 |
|
| 299 |
array( |
| 300 |
'id' => 'button_hover_bg_color', |
| 301 |
'type' => 'color', |
| 302 |
'title' => esc_html__( 'Gift button Hover background color', 'merchant' ), |
| 303 |
'default' => '#7167e1', |
| 304 |
), |
| 305 |
|
| 306 |
array( |
| 307 |
'id' => 'button_text_color', |
| 308 |
'type' => 'color', |
| 309 |
'title' => esc_html__( 'Gift button Icon color', 'merchant' ), |
| 310 |
'default' => '#fff', |
| 311 |
), |
| 312 |
|
| 313 |
array( |
| 314 |
'id' => 'content_width', |
| 315 |
'type' => 'range', |
| 316 |
'title' => esc_html__( 'Content width', 'merchant' ), |
| 317 |
'min' => 0, |
| 318 |
'max' => 600, |
| 319 |
'step' => 1, |
| 320 |
'unit' => 'px', |
| 321 |
'default' => 300, |
| 322 |
), |
| 323 |
|
| 324 |
array( |
| 325 |
'id' => 'content_bg_color', |
| 326 |
'type' => 'color', |
| 327 |
'title' => esc_html__( 'Content background color', 'merchant' ), |
| 328 |
'default' => '#fff', |
| 329 |
), |
| 330 |
|
| 331 |
array( |
| 332 |
'id' => 'label_bg_color', |
| 333 |
'type' => 'color', |
| 334 |
'title' => esc_html__( 'Label background color', 'merchant' ), |
| 335 |
'default' => '#f5f5f5', |
| 336 |
), |
| 337 |
|
| 338 |
array( |
| 339 |
'id' => 'label_text_color', |
| 340 |
'type' => 'color', |
| 341 |
'title' => esc_html__( 'Label text color', 'merchant' ), |
| 342 |
'default' => '#212121', |
| 343 |
), |
| 344 |
|
| 345 |
array( |
| 346 |
'id' => 'product_text_color', |
| 347 |
'type' => 'color', |
| 348 |
'title' => esc_html__( 'Product text color', 'merchant' ), |
| 349 |
'default' => '#212121', |
| 350 |
), |
| 351 |
|
| 352 |
array( |
| 353 |
'id' => 'product_text_hover_color', |
| 354 |
'type' => 'color', |
| 355 |
'title' => esc_html__( 'Product hover text color', 'merchant' ), |
| 356 |
'default' => '#757575', |
| 357 |
), |
| 358 |
|
| 359 |
array( |
| 360 |
'id' => 'product_price_text_color', |
| 361 |
'type' => 'color', |
| 362 |
'title' => esc_html__( 'Product price text color', 'merchant' ), |
| 363 |
'default' => '#999999', |
| 364 |
), |
| 365 |
|
| 366 |
array( |
| 367 |
'id' => 'free_text_color', |
| 368 |
'type' => 'color', |
| 369 |
'title' => esc_html__( 'Gift price label color', 'merchant' ), |
| 370 |
'default' => '#212121', |
| 371 |
), |
| 372 |
), |
| 373 |
) |
| 374 |
); |
| 375 |
|