| 1 |
<?php |
| 2 |
/** |
| 3 |
* Clear Cart |
| 4 |
* |
| 5 |
* @package Merchant |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit if accessed directly |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Settings |
| 14 |
*/ |
| 15 |
|
| 16 |
return array( |
| 17 |
array( |
| 18 |
'title' => esc_html__( 'Settings', 'merchant' ), |
| 19 |
'module' => Merchant_Clear_Cart::MODULE_ID, |
| 20 |
'fields' => array( |
| 21 |
array( |
| 22 |
'id' => 'cart_threshold', |
| 23 |
'type' => 'number', |
| 24 |
'title' => esc_html__( 'Cart Item Threshold', 'merchant' ), |
| 25 |
'desc' => esc_html__( 'Show a "Clear Cart" button when the cart contains at least this many items.', 'merchant' ), |
| 26 |
'step' => 1, |
| 27 |
'default' => 1, |
| 28 |
), |
| 29 |
|
| 30 |
array( |
| 31 |
'id' => 'enable_auto_clear', |
| 32 |
'type' => 'switcher', |
| 33 |
'title' => __( 'Clear Cart After Inactivity', 'merchant' ), |
| 34 |
'desc' => __( 'Show a prompt to clear the cart when there\'s no user activity for this amount of time.', 'merchant' ), |
| 35 |
'default' => 0, |
| 36 |
'ai_meta' => array( |
| 37 |
'toggle_for' => 'auto_clear_expiration_hours', |
| 38 |
'usage_hint' => 'Enable to automatically prompt users to clear their cart after inactivity. Gates auto_clear_expiration_hours. Also changes the confirmation dialog to popup_message_inactive.', |
| 39 |
), |
| 40 |
), |
| 41 |
|
| 42 |
array( |
| 43 |
'id' => 'auto_clear_expiration_hours', |
| 44 |
'type' => 'number', |
| 45 |
'title' => esc_html__( 'Time of Cart Session Expiration', 'merchant' ), |
| 46 |
'desc' => esc_html__( 'After this number of hours with no activity, the user will be prompted to clear their cart.', 'merchant' ), |
| 47 |
'step' => 1, |
| 48 |
'condition' => array( 'enable_auto_clear', '==', '1' ), |
| 49 |
'default' => 24, |
| 50 |
'ai_meta' => array( |
| 51 |
'toggled_by' => 'enable_auto_clear', |
| 52 |
'usage_hint' => 'Inactivity duration in hours before the clear-cart prompt appears. Only applies when enable_auto_clear is enabled.', |
| 53 |
), |
| 54 |
), |
| 55 |
|
| 56 |
array( |
| 57 |
'id' => 'popup_message', |
| 58 |
'type' => 'text', |
| 59 |
'title' => esc_html__( 'Confirmation Message', 'merchant' ), |
| 60 |
'desc' => esc_html__( 'Clear cart confirmation dialog box', 'merchant' ), |
| 61 |
'default' => esc_html__( 'Are you sure you want to empty your shopping cart?', 'merchant' ), |
| 62 |
'conditions' => array( |
| 63 |
'terms' => array( |
| 64 |
array( |
| 65 |
'field' => 'enable_auto_clear', |
| 66 |
'operator' => '===', |
| 67 |
'value' => false, |
| 68 |
), |
| 69 |
), |
| 70 |
), |
| 71 |
), |
| 72 |
|
| 73 |
array( |
| 74 |
'id' => 'popup_message_inactive', |
| 75 |
'type' => 'text', |
| 76 |
'title' => esc_html__( 'Inactive Confirmation Message', 'merchant' ), |
| 77 |
'desc' => esc_html__( 'Clear cart confirmation dialog box', 'merchant' ), |
| 78 |
'default' => esc_html__( 'It looks like you haven’t been active for a while. Would you like to empty your shopping cart?', 'merchant' ), |
| 79 |
'condition' => array( 'enable_auto_clear', '==', '1' ), |
| 80 |
), |
| 81 |
|
| 82 |
array( |
| 83 |
'id' => 'redirect_link', |
| 84 |
'type' => 'radio', |
| 85 |
'title' => esc_html__( 'Redirect URL after Clearing the Cart', 'merchant' ), |
| 86 |
'options' => array( |
| 87 |
'' => esc_html__( 'None', 'merchant' ), |
| 88 |
'home' => esc_html__( 'Home', 'merchant' ), |
| 89 |
'shop' => esc_html__( 'Shop', 'merchant' ), |
| 90 |
'custom' => esc_html__( 'Custom', 'merchant' ), |
| 91 |
), |
| 92 |
'default' => '', |
| 93 |
'ai_meta' => array( |
| 94 |
'toggle_for' => 'redirect_link_custom', |
| 95 |
'usage_hint' => 'Where to send the user after clearing the cart. Set to custom and fill redirect_link_custom for a specific URL. Leave empty (None) to stay on the current page.', |
| 96 |
), |
| 97 |
), |
| 98 |
|
| 99 |
array( |
| 100 |
'id' => 'redirect_link_custom', |
| 101 |
'type' => 'text', |
| 102 |
'title' => esc_html__( 'Custom Redirect URL', 'merchant' ), |
| 103 |
'desc' => esc_html__( 'Enter a custom URL to redirect users to a specific page.', 'merchant' ), |
| 104 |
'placeholder' => esc_attr( 'https://yourdomain.com/page-slug' ), |
| 105 |
'default' => '', |
| 106 |
'condition' => array( 'redirect_link', '==', 'custom' ), |
| 107 |
'ai_meta' => array( |
| 108 |
'toggled_by' => 'redirect_link', |
| 109 |
'usage_hint' => 'The full URL to redirect to after clearing the cart. Only active when redirect_link=custom.', |
| 110 |
), |
| 111 |
), |
| 112 |
), |
| 113 |
), |
| 114 |
array( |
| 115 |
'title' => esc_html__( 'Placement', 'merchant' ), |
| 116 |
'module' => Merchant_Clear_Cart::MODULE_ID, |
| 117 |
'fields' => array( |
| 118 |
array( |
| 119 |
'id' => 'enable_cart_page', |
| 120 |
'type' => 'switcher', |
| 121 |
'title' => __( 'Cart Page', 'merchant' ), |
| 122 |
'default' => 1, |
| 123 |
'ai_meta' => array( |
| 124 |
'toggle_for' => 'cart_page_position', |
| 125 |
'usage_hint' => 'Show the Clear Cart button on the WooCommerce cart page. Enable this before setting cart_page_position.', |
| 126 |
), |
| 127 |
), |
| 128 |
|
| 129 |
array( |
| 130 |
'id' => 'cart_page_position', |
| 131 |
'type' => 'select', |
| 132 |
'title' => esc_html__( 'Position', 'merchant' ), |
| 133 |
'options' => array( |
| 134 |
'woocommerce_cart_coupon' => esc_html__( 'After Coupon Button', 'merchant' ), |
| 135 |
'woocommerce_cart_actions' => esc_html__( 'After Update Cart Button', 'merchant' ), |
| 136 |
'woocommerce_after_cart_table' => esc_html__( 'After Cart Table', 'merchant' ), |
| 137 |
), |
| 138 |
'condition' => array( 'enable_cart_page', '==', '1' ), |
| 139 |
'default' => 'woocommerce_cart_coupon', |
| 140 |
'ai_meta' => array( |
| 141 |
'toggled_by' => 'enable_cart_page', |
| 142 |
'usage_hint' => 'Where the Clear Cart button appears on the cart page. Requires enable_cart_page=true.', |
| 143 |
), |
| 144 |
), |
| 145 |
|
| 146 |
array( |
| 147 |
'id' => 'enable_mini_cart', |
| 148 |
'type' => 'switcher', |
| 149 |
'title' => __( 'Mini Cart', 'merchant' ), |
| 150 |
'default' => 0, |
| 151 |
'ai_meta' => array( |
| 152 |
'toggle_for' => 'mini_cart_position', |
| 153 |
'usage_hint' => 'Show the Clear Cart button inside the WooCommerce mini cart widget. Enable before setting mini_cart_position.', |
| 154 |
), |
| 155 |
), |
| 156 |
|
| 157 |
array( |
| 158 |
'id' => 'mini_cart_position', |
| 159 |
'type' => 'select', |
| 160 |
'title' => esc_html__( 'Position', 'merchant' ), |
| 161 |
'options' => array( |
| 162 |
'before_view_cart' => esc_html__( 'Before View Cart Button', 'merchant' ), |
| 163 |
'after_view_cart' => esc_html__( 'After View Cart Button', 'merchant' ), |
| 164 |
'after_checkout' => esc_html__( 'After Checkout Button', 'merchant' ), |
| 165 |
), |
| 166 |
'default' => 'after_checkout', |
| 167 |
'condition' => array( 'enable_mini_cart', '==', '1' ), |
| 168 |
'ai_meta' => array( |
| 169 |
'toggled_by' => 'enable_mini_cart', |
| 170 |
'usage_hint' => 'Where the Clear Cart button appears inside the mini cart. Requires enable_mini_cart=true.', |
| 171 |
), |
| 172 |
), |
| 173 |
|
| 174 |
array( |
| 175 |
'id' => 'enable_side_cart', |
| 176 |
'type' => 'switcher', |
| 177 |
'title' => esc_html__( 'Side Cart', 'merchant' ), |
| 178 |
'pro' => true, |
| 179 |
'default' => 0, |
| 180 |
'ai_meta' => array( |
| 181 |
'toggle_for' => 'side_cart_position', |
| 182 |
'usage_hint' => 'Show the Clear Cart button inside the Merchant Side Cart module. Enable before setting side_cart_position. Requires Merchant Pro and the Side Cart module to be active.', |
| 183 |
), |
| 184 |
), |
| 185 |
|
| 186 |
array( |
| 187 |
'id' => 'side_cart_position', |
| 188 |
'type' => 'select', |
| 189 |
'pro' => true, |
| 190 |
'title' => esc_html__( 'Position', 'merchant' ), |
| 191 |
'options' => array( |
| 192 |
'before_view_cart' => esc_html__( 'Before View Cart Button', 'merchant' ), |
| 193 |
'after_view_cart' => esc_html__( 'After View Cart Button', 'merchant' ), |
| 194 |
'before_checkout' => esc_html__( 'Before Checkout Button', 'merchant' ), |
| 195 |
), |
| 196 |
'default' => 'after_view_cart', |
| 197 |
'condition' => array( 'enable_side_cart', '==', '1' ), |
| 198 |
'ai_meta' => array( |
| 199 |
'toggled_by' => 'enable_side_cart', |
| 200 |
'usage_hint' => 'Where the Clear Cart button appears inside the side cart. Requires enable_side_cart=true.', |
| 201 |
), |
| 202 |
), |
| 203 |
|
| 204 |
array( |
| 205 |
'id' => 'side_cart_info', |
| 206 |
'pro' => true, |
| 207 |
'type' => 'info_block', |
| 208 |
'description' => esc_html__( 'To add a Clear Cart button to the Side Cart, you need to activate the Side Cart module.', 'merchant' ), |
| 209 |
'button_text' => esc_html__( 'View Side Cart', 'merchant' ), |
| 210 |
'button_link' => esc_url( admin_url( 'admin.php?page=merchant&module=side-cart' ) ), |
| 211 |
'condition' => array( 'enable_side_cart', '==', '1' ), |
| 212 |
), |
| 213 |
), |
| 214 |
), |
| 215 |
array( |
| 216 |
'title' => esc_html__( 'Look and Feel', 'merchant' ), |
| 217 |
'module' => Merchant_Clear_Cart::MODULE_ID, |
| 218 |
'fields' => array( |
| 219 |
array( |
| 220 |
'id' => 'label', |
| 221 |
'type' => 'text', |
| 222 |
'title' => esc_html__( 'Label', 'merchant' ), |
| 223 |
'default' => esc_html__( 'Clear Cart', 'merchant' ), |
| 224 |
), |
| 225 |
|
| 226 |
array( |
| 227 |
'id' => 'style', |
| 228 |
'type' => 'radio', |
| 229 |
'title' => esc_html__( 'Style', 'merchant' ), |
| 230 |
'options' => array( |
| 231 |
'solid' => esc_html__( 'Solid', 'merchant' ), |
| 232 |
'outline' => esc_html__( 'Outline', 'merchant' ), |
| 233 |
'text' => esc_html__( 'Text', 'merchant' ), |
| 234 |
), |
| 235 |
'default' => 'solid', |
| 236 |
), |
| 237 |
|
| 238 |
array( |
| 239 |
'id' => 'border_width', |
| 240 |
'type' => 'range', |
| 241 |
'title' => esc_html__( 'Outline', 'merchant' ), |
| 242 |
'min' => 1, |
| 243 |
'max' => 20, |
| 244 |
'step' => 1, |
| 245 |
'unit' => 'px', |
| 246 |
'default' => 2, |
| 247 |
'condition' => array( 'style', '==', 'outline' ), |
| 248 |
), |
| 249 |
|
| 250 |
array( |
| 251 |
'id' => 'border_radius', |
| 252 |
'type' => 'range', |
| 253 |
'title' => esc_html__( 'Border Radius', 'merchant' ), |
| 254 |
'min' => 0, |
| 255 |
'max' => 999, |
| 256 |
'step' => 1, |
| 257 |
'unit' => 'px', |
| 258 |
'default' => 0, |
| 259 |
'condition' => array( 'style', 'any', 'solid|outline' ), |
| 260 |
), |
| 261 |
|
| 262 |
array( |
| 263 |
'id' => 'padding_vertical', |
| 264 |
'type' => 'range', |
| 265 |
'title' => esc_html__( 'Padding Top/Bottom', 'merchant' ), |
| 266 |
'min' => 0, |
| 267 |
'max' => 100, |
| 268 |
'step' => 1, |
| 269 |
'default' => 15, |
| 270 |
'unit' => 'px', |
| 271 |
'condition' => array( 'style', 'any', 'solid|outline' ), |
| 272 |
), |
| 273 |
|
| 274 |
array( |
| 275 |
'id' => 'padding_horizontal', |
| 276 |
'type' => 'range', |
| 277 |
'title' => esc_html__( 'Padding Left/Right', 'merchant' ), |
| 278 |
'min' => 0, |
| 279 |
'max' => 100, |
| 280 |
'step' => 1, |
| 281 |
'default' => 25, |
| 282 |
'unit' => 'px', |
| 283 |
'condition' => array( 'style', 'any', 'solid|outline' ), |
| 284 |
), |
| 285 |
|
| 286 |
array( |
| 287 |
'id' => 'background_color', |
| 288 |
'type' => 'color', |
| 289 |
'title' => esc_html__( 'Button Background Color', 'merchant' ), |
| 290 |
'default' => '#212121', |
| 291 |
'condition' => array( 'style', '==', 'solid' ), |
| 292 |
), |
| 293 |
|
| 294 |
array( |
| 295 |
'id' => 'background_color_hover', |
| 296 |
'type' => 'color', |
| 297 |
'title' => esc_html__( 'Button Background Hover Color', 'merchant' ), |
| 298 |
'default' => '#414141', |
| 299 |
'condition' => array( 'style', '==', 'solid' ), |
| 300 |
), |
| 301 |
|
| 302 |
array( |
| 303 |
'id' => 'text_color', |
| 304 |
'type' => 'color', |
| 305 |
'title' => esc_html__( 'Button Text Color', 'merchant' ), |
| 306 |
'default' => '#ffffff', |
| 307 |
), |
| 308 |
|
| 309 |
array( |
| 310 |
'id' => 'text_color_hover', |
| 311 |
'type' => 'color', |
| 312 |
'title' => esc_html__( 'Button Text Hover Color', 'merchant' ), |
| 313 |
'default' => '#ffffff', |
| 314 |
), |
| 315 |
|
| 316 |
array( |
| 317 |
'id' => 'border_color', |
| 318 |
'type' => 'color', |
| 319 |
'title' => esc_html__( 'Button Outline Color', 'merchant' ), |
| 320 |
'default' => '#212121', |
| 321 |
'condition' => array( 'style', '==', 'outline' ), |
| 322 |
), |
| 323 |
|
| 324 |
array( |
| 325 |
'id' => 'border_color_hover', |
| 326 |
'type' => 'color', |
| 327 |
'title' => esc_html__( 'Button Outline Hover Color', 'merchant' ), |
| 328 |
'default' => '#414141', |
| 329 |
'condition' => array( 'style', '==', 'outline' ), |
| 330 |
), |
| 331 |
|
| 332 |
array( |
| 333 |
'id' => 'font_size', |
| 334 |
'type' => 'range', |
| 335 |
'title' => esc_html__( 'Font size', 'merchant' ), |
| 336 |
'min' => 1, |
| 337 |
'max' => 100, |
| 338 |
'step' => 1, |
| 339 |
'default' => 16, |
| 340 |
'unit' => 'px', |
| 341 |
), |
| 342 |
), |
| 343 |
), |
| 344 |
array( |
| 345 |
'module' => Merchant_Clear_Cart::MODULE_ID, |
| 346 |
'title' => esc_html__( 'Use shortcode', 'merchant' ), |
| 347 |
'fields' => array( |
| 348 |
array( |
| 349 |
'id' => 'use_shortcode', |
| 350 |
'type' => 'switcher', |
| 351 |
'title' => __( 'Use shortcode', 'merchant' ), |
| 352 |
'default' => 0, |
| 353 |
), |
| 354 |
|
| 355 |
array( |
| 356 |
'type' => 'info', |
| 357 |
'id' => 'shortcode_info', |
| 358 |
'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.', 'merchant' ), |
| 359 |
), |
| 360 |
|
| 361 |
array( |
| 362 |
'id' => 'shortcode_text', |
| 363 |
'type' => 'text_readonly', |
| 364 |
'title' => esc_html__( 'Shortcode text', 'merchant' ), |
| 365 |
'default' => '[merchant_module_' . str_replace( '-', '_', Merchant_Clear_Cart::MODULE_ID ) . ']', |
| 366 |
'condition' => array( 'use_shortcode', '==', '1' ), |
| 367 |
), |
| 368 |
), |
| 369 |
), |
| 370 |
); |
| 371 |
|