← All changes
|
includes/elementor/modules/checkout/widgets/settings-controls.php
+115
-18
1.1.4
→
2.7.0
View file →
| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | |
| 5 | 5 | defined( 'ABSPATH' ) || die(); |
| 6 | 6 | |
| 7 | 7 | use Elementor\Settings; |
| 8 | +use Elementor\Plugin; | |
| 8 | 9 | |
| 9 | 10 | /** |
| 10 | 11 | * Checkout settings controls. |
| 11 | 12 | * |
| @@ -32,11 +33,13 @@ | ||
| 32 | 33 | 'shipping_city' => esc_html__( 'Shipping City', 'sellkit' ), |
| 33 | 34 | 'shipping_postcode' => esc_html__( 'Shipping Postcode', 'sellkit' ), |
| 34 | 35 | 'shipping_country' => esc_html__( 'Shipping Country', 'sellkit' ), |
| 35 | 36 | 'shipping_state' => esc_html__( 'Shipping State', 'sellkit' ), |
| 37 | + 'custom_field_pro' => esc_html__( 'Custom Field (Sellkit Pro)', 'sellkit' ), | |
| 36 | 38 | ]; |
| 37 | 39 | |
| 38 | 40 | if ( sellkit()->has_pro ) { |
| 41 | + unset( $fields['custom_field_pro'] ); | |
| 39 | 42 | $fields = \Sellkit_Elementor_Checkout_Pro_Module::checkout_custom_fields( $fields ); |
| 40 | 43 | } |
| 41 | 44 | |
| 42 | 45 | return $fields; |
| @@ -53,11 +56,13 @@ | ||
| 53 | 56 | 'billing_postcode' => esc_html__( 'Billing Postcode', 'sellkit' ), |
| 54 | 57 | 'billing_country' => esc_html__( 'Billing Country', 'sellkit' ), |
| 55 | 58 | 'billing_state' => esc_html__( 'Billing State', 'sellkit' ), |
| 56 | 59 | 'billing_phone' => esc_html__( 'Billing Phone', 'sellkit' ), |
| 60 | + 'custom_field_pro' => esc_html__( 'Custom Field (Sellkit Pro)', 'sellkit' ), | |
| 57 | 61 | ]; |
| 58 | 62 | |
| 59 | 63 | if ( sellkit()->has_pro ) { |
| 64 | + unset( $fields['custom_field_pro'] ); | |
| 60 | 65 | $fields = \Sellkit_Elementor_Checkout_Pro_Module::checkout_custom_fields( $fields ); |
| 61 | 66 | } |
| 62 | 67 | |
| 63 | 68 | return $fields; |
| @@ -154,20 +159,34 @@ | ||
| 154 | 159 | ); |
| 155 | 160 | |
| 156 | 161 | if ( sellkit()->has_pro ) { |
| 157 | 162 | \Sellkit_Elementor_Checkout_Pro_Module::express_checkout_control( $this ); |
| 163 | + } else { | |
| 164 | + $this->add_control( | |
| 165 | + 'show_express_checkout_promotions', | |
| 166 | + [ | |
| 167 | + 'label' => esc_html__( 'Express Checkout', 'sellkit' ), | |
| 168 | + 'classes' => 'elementor-control-checkout-express-promotion', | |
| 169 | + 'type' => 'switcher', | |
| 170 | + 'label_on' => esc_html__( 'Show', 'sellkit' ), | |
| 171 | + 'label_off' => esc_html__( 'Hide', 'sellkit' ), | |
| 172 | + 'return_value' => 'yes', | |
| 173 | + 'default' => 'no', | |
| 174 | + ] | |
| 175 | + ); | |
| 158 | 176 | } |
| 159 | 177 | |
| 160 | 178 | $this->add_control( |
| 161 | 179 | 'show_sticky_cart_details', |
| 162 | 180 | [ |
| 163 | - 'label' => esc_html__( 'Checkout Sticky Cart', 'sellkit' ), | |
| 164 | - 'type' => 'switcher', | |
| 165 | - 'label_on' => esc_html__( 'Show', 'sellkit' ), | |
| 166 | - 'label_off' => esc_html__( 'Hide', 'sellkit' ), | |
| 181 | + 'label' => esc_html__( 'Checkout Sticky Cart', 'sellkit' ), | |
| 182 | + 'type' => 'switcher', | |
| 183 | + 'frontend_available' => true, | |
| 184 | + 'label_on' => esc_html__( 'Show', 'sellkit' ), | |
| 185 | + 'label_off' => esc_html__( 'Hide', 'sellkit' ), | |
| 167 | 186 | 'return_value' => 'yes', |
| 168 | - 'default' => 'yes', | |
| 169 | - 'condition' => [ | |
| 187 | + 'default' => 'yes', | |
| 188 | + 'condition' => [ | |
| 170 | 189 | 'layout-type' => 'multi-step', |
| 171 | 190 | ], |
| 172 | 191 | ] |
| 173 | 192 | ); |
| @@ -172,8 +191,21 @@ | ||
| 172 | 191 | ] |
| 173 | 192 | ); |
| 174 | 193 | |
| 175 | 194 | $this->add_control( |
| 195 | + 'sticky_cart_offset', | |
| 196 | + [ | |
| 197 | + 'label' => esc_html__( 'Offset', 'sellkit' ), | |
| 198 | + 'type' => 'number', | |
| 199 | + 'frontend_available' => true, | |
| 200 | + 'condition' => [ | |
| 201 | + 'layout-type' => 'multi-step', | |
| 202 | + 'show_sticky_cart_details' => 'yes', | |
| 203 | + ], | |
| 204 | + ] | |
| 205 | + ); | |
| 206 | + | |
| 207 | + $this->add_control( | |
| 176 | 208 | 'place_order_btn_txt', |
| 177 | 209 | [ |
| 178 | 210 | 'label' => esc_html__( 'Place Order Button Text', 'sellkit' ), |
| 179 | 211 | 'type' => 'text', |
| @@ -184,12 +216,69 @@ | ||
| 184 | 216 | |
| 185 | 217 | $this->end_controls_section(); |
| 186 | 218 | } |
| 187 | 219 | |
| 220 | + public function get_template( $texts ) { | |
| 221 | + ob_start(); | |
| 222 | + ?> | |
| 223 | + <div class="elementor-nerd-box"> | |
| 224 | + <span class="sellkit-checkout-promotion-rocket"></span> | |
| 225 | + <div class="sellkit-checkout-autocomplete-promotion-title"><?php echo esc_html( $texts['title'] ); ?></div> | |
| 226 | + <?php foreach ( $texts['messages'] as $message ) { ?> | |
| 227 | + <div class="sellkit-checkout-promotion-message"><?php echo wp_kses_post( $message ); ?></div> | |
| 228 | + <?php } | |
| 229 | + | |
| 230 | + // Show a `Go Pro` button only if the user doesn't have Pro. | |
| 231 | + if ( $texts['link'] ) { ?> | |
| 232 | + <a | |
| 233 | + class="sellkit-checkout-autocomplete-promotion-btn" | |
| 234 | + href="https://getsellkit.com/pricing/" | |
| 235 | + target="_blank" | |
| 236 | + > | |
| 237 | + <?php echo esc_html__( 'Upgrade Now', 'sellkit' ); ?> | |
| 238 | + </a> | |
| 239 | + <?php } ?> | |
| 240 | + </div> | |
| 241 | + <?php | |
| 242 | + | |
| 243 | + return ob_get_clean(); | |
| 244 | + } | |
| 245 | + | |
| 188 | 246 | private function google_autocomplete_settings() { |
| 189 | 247 | if ( sellkit()->has_pro ) { |
| 190 | 248 | \Sellkit_Elementor_Checkout_Pro_Module::google_address_autocomplete( $this ); |
| 249 | + return; | |
| 191 | 250 | } |
| 251 | + | |
| 252 | + $messages = [ | |
| 253 | + sprintf( | |
| 254 | + /* translators: 1: bold tag 2: bold tag */ | |
| 255 | + esc_html__( 'You are using a free version of Sellkit. Upgrade to %1$s Sellkit Pro %2$s to use this feature.', 'sellkit' ), | |
| 256 | + '<b>', | |
| 257 | + '</b>' | |
| 258 | + ), | |
| 259 | + ]; | |
| 260 | + | |
| 261 | + $this->start_controls_section( | |
| 262 | + 'google_autocomplete_settings', | |
| 263 | + [ | |
| 264 | + 'label' => esc_html__( 'Address Autocomplete', 'sellkit' ), | |
| 265 | + ] | |
| 266 | + ); | |
| 267 | + | |
| 268 | + $this->add_control( | |
| 269 | + 'sellkit_checkout_autocomplete_address_promotion', | |
| 270 | + [ | |
| 271 | + 'type' => 'raw_html', | |
| 272 | + 'raw' => $this->get_template( [ | |
| 273 | + 'title' => esc_html__( 'Upgrade to Sellkit Pro', 'sellkit' ), | |
| 274 | + 'messages' => $messages, | |
| 275 | + 'link' => 'https://getsellkit.com/pricing/', | |
| 276 | + ] ), | |
| 277 | + ] | |
| 278 | + ); | |
| 279 | + | |
| 280 | + $this->end_controls_section(); | |
| 192 | 281 | } |
| 193 | 282 | |
| 194 | 283 | private function coupon_form_visibility() { |
| 195 | 284 | $this->start_controls_section( |
| @@ -239,9 +328,9 @@ | ||
| 239 | 328 | |
| 240 | 329 | $repeater->add_control( |
| 241 | 330 | 'shipping_list_field', |
| 242 | 331 | [ |
| 243 | - 'label' => esc_html__( 'Select Field role', 'sellkit' ), | |
| 332 | + 'label' => esc_html__( 'Field role', 'sellkit' ), | |
| 244 | 333 | 'type' => 'select', |
| 245 | 334 | 'options' => $this->shipping_fields_type(), |
| 246 | 335 | ] |
| 247 | 336 | ); |
| @@ -389,16 +478,19 @@ | ||
| 389 | 478 | |
| 390 | 479 | $repeater->add_control( |
| 391 | 480 | 'shipping_list_validation', |
| 392 | 481 | [ |
| 393 | - 'label' => esc_html__( 'Validation', 'sellkit' ), | |
| 394 | - 'type' => 'select', | |
| 395 | - 'options' => [ | |
| 482 | + 'label' => esc_html__( 'Validation', 'sellkit' ), | |
| 483 | + 'type' => 'select', | |
| 484 | + 'options' => [ | |
| 396 | 485 | '' => esc_html__( 'Select one...', 'sellkit' ), |
| 397 | 486 | 'phone' => esc_html__( 'Phone validation', 'sellkit' ), |
| 398 | 487 | 'postcode' => esc_html__( 'Postcode Validation', 'sellkit' ), |
| 399 | 488 | ], |
| 400 | - 'default' => '', | |
| 489 | + 'default' => '', | |
| 490 | + 'condition' => [ | |
| 491 | + 'shipping_custom_type' => [ 'text', 'select', 'tel' ], | |
| 492 | + ], | |
| 401 | 493 | ] |
| 402 | 494 | ); |
| 403 | 495 | |
| 404 | 496 | $repeater->add_control( |
| @@ -466,8 +558,9 @@ | ||
| 466 | 558 | 'fields' => $repeater->get_controls(), |
| 467 | 559 | 'item_actions' => [ |
| 468 | 560 | 'duplicate' => false, |
| 469 | 561 | ], |
| 562 | + 'prevent_empty' => false, | |
| 470 | 563 | 'default' => [ |
| 471 | 564 | [ |
| 472 | 565 | 'shipping_list_field' => 'shipping_first_name', |
| 473 | 566 | 'shipping_list_placeholder' => esc_html__( 'First Name', 'sellkit' ), |
| @@ -524,9 +617,9 @@ | ||
| 524 | 617 | 'shipping_list_required' => 'no', |
| 525 | 618 | 'shipping_list_clear' => 'no', |
| 526 | 619 | ], |
| 527 | 620 | ], |
| 528 | - 'title_field' => '{{{ shipping_list_field }}}', | |
| 621 | + 'title_field' => '{{{ shipping_list_placeholder }}}', | |
| 529 | 622 | ] |
| 530 | 623 | ); |
| 531 | 624 | |
| 532 | 625 | $this->end_controls_section(); |
| @@ -545,9 +638,9 @@ | ||
| 545 | 638 | /* Prevent user to add email field , we added that at login form. billing_email excluded. */ |
| 546 | 639 | $repeater->add_control( |
| 547 | 640 | 'billing_list_field', |
| 548 | 641 | [ |
| 549 | - 'label' => esc_html__( 'Select Field role', 'sellkit' ), | |
| 642 | + 'label' => esc_html__( 'Field role', 'sellkit' ), | |
| 550 | 643 | 'type' => 'select', |
| 551 | 644 | 'options' => $this->billing_fields_type(), |
| 552 | 645 | ] |
| 553 | 646 | ); |
| @@ -695,16 +788,19 @@ | ||
| 695 | 788 | |
| 696 | 789 | $repeater->add_control( |
| 697 | 790 | 'billing_list_validation', |
| 698 | 791 | [ |
| 699 | - 'label' => esc_html__( 'Validation', 'sellkit' ), | |
| 700 | - 'type' => 'select', | |
| 701 | - 'options' => [ | |
| 792 | + 'label' => esc_html__( 'Validation', 'sellkit' ), | |
| 793 | + 'type' => 'select', | |
| 794 | + 'options' => [ | |
| 702 | 795 | '' => esc_html__( 'Select one...', 'sellkit' ), |
| 703 | 796 | 'phone' => esc_html__( 'Phone validation', 'sellkit' ), |
| 704 | 797 | 'postcode' => esc_html__( 'Postcode Validation', 'sellkit' ), |
| 705 | 798 | ], |
| 706 | - 'default' => '', | |
| 799 | + 'default' => '', | |
| 800 | + 'condition' => [ | |
| 801 | + 'billing_custom_type' => [ 'text', 'select', 'tel' ], | |
| 802 | + ], | |
| 707 | 803 | ] |
| 708 | 804 | ); |
| 709 | 805 | |
| 710 | 806 | $repeater->add_control( |
| @@ -772,8 +868,9 @@ | ||
| 772 | 868 | 'fields' => $repeater->get_controls(), |
| 773 | 869 | 'item_actions' => [ |
| 774 | 870 | 'duplicate' => false, |
| 775 | 871 | ], |
| 872 | + 'prevent_empty' => false, | |
| 776 | 873 | 'default' => [ |
| 777 | 874 | [ |
| 778 | 875 | 'billing_list_field' => 'billing_first_name', |
| 779 | 876 | 'billing_list_placeholder' => esc_html__( 'First Name', 'sellkit' ), |
| @@ -830,9 +927,9 @@ | ||
| 830 | 927 | 'billing_list_required' => 'no', |
| 831 | 928 | 'billing_list_clear' => 'no', |
| 832 | 929 | ], |
| 833 | 930 | ], |
| 834 | - 'title_field' => '{{{ billing_list_field }}}', | |
| 931 | + 'title_field' => '{{{ billing_list_placeholder }}}', | |
| 835 | 932 | ] |
| 836 | 933 | ); |
| 837 | 934 | |
| 838 | 935 | $this->end_controls_section(); |