PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 2.7.0
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v2.7.0
2.7.0 2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 All 43 releases
← All changes | includes/elementor/modules/checkout/classes/helper.php +51 -7 1.6.22.7.0 View file →
@@ -47,8 +47,9 @@
47 47 public function billing_fields() {
48 48 return [
49 49 'billing_first_name' => esc_html__( 'Billing First Name', 'sellkit' ),
50 50 'billing_last_name' => esc_html__( 'Billing Last Name', 'sellkit' ),
51 + 'billing_company' => esc_html__( 'Billing Company', 'sellkit' ),
51 52 'billing_address_1' => esc_html__( 'Billing Address 1', 'sellkit' ),
52 53 'billing_address_2' => esc_html__( 'Billing Address 2', 'sellkit' ),
53 54 'billing_city' => esc_html__( 'Billing City', 'sellkit' ),
54 55 'billing_postcode' => esc_html__( 'Billing Postal Code', 'sellkit' ),
@@ -54,8 +55,9 @@
54 55 'billing_postcode' => esc_html__( 'Billing Postal Code', 'sellkit' ),
55 56 'billing_country' => esc_html__( 'Billing Country', 'sellkit' ),
56 57 'billing_state' => esc_html__( 'Billing State', 'sellkit' ),
57 58 'billing_email' => esc_html__( 'Billing State', 'sellkit' ),
59 + 'billing_phone' => esc_html__( 'Billing Phone', 'sellkit' ),
58 60 ];
59 61 }
60 62
61 63 /**
@@ -88,9 +90,11 @@
88 90 public function get_user_defined_fields_slug( $user_defined_fields, $type ) {
89 91 $fields = [];
90 92
91 93 foreach ( $user_defined_fields as $field ) {
92 - $fields[] = $field[ $type ];
94 + if ( isset( $field[ $type ] ) ) {
95 + $fields[] = $field[ $type ];
96 + }
93 97 }
94 98
95 99 return $fields;
96 100 }
@@ -236,10 +240,13 @@
236 240 * @param array $shipping_fields custom shipping fields.
237 241 * @param array $billing_fields custom billing fields.
238 242 * @return void
239 243 * @since 1.1.0
244 + * @SuppressWarnings(PHPMD.CyclomaticComplexity)
240 245 */
241 246 public function validate_user_defined_fields( $shipping_fields, $billing_fields ) {
247 + $shipping_destination = get_option( 'woocommerce_ship_to_destination', true );
248 +
242 249 foreach ( $shipping_fields as $data ) {
243 250 // Escape all if cart does not need shipping information.
244 251 if ( ! WC()->cart->needs_shipping() ) {
245 252 continue;
@@ -244,10 +251,15 @@
244 251 if ( ! WC()->cart->needs_shipping() ) {
245 252 continue;
246 253 }
247 254
248 - $final_name = $data['shipping_list_field'];
255 + // Escape all if shipping destination be billing only.
256 + if ( 'billing_only' === $shipping_destination ) {
257 + continue;
258 + }
249 259
260 + $final_name = isset( $data['shipping_list_field'] ) ? $data['shipping_list_field'] : '';
261 +
250 262 if ( 'custom_role' === $final_name ) {
251 263 $final_name = 'shipping_' . $data['_id'];
252 264
253 265 if ( ! empty( $data['shipping_custom_id'] ) ) {
@@ -277,9 +289,9 @@
277 289 $this->postcode_validation( $data, $final_name, 'shipping', $label );
278 290 }
279 291
280 292 foreach ( $billing_fields as $data ) {
281 - $final_name = $data['billing_list_field'];
293 + $final_name = isset( $data['billing_list_field'] ) ? $data['billing_list_field'] : '';
282 294
283 295 if ( 'custom_role' !== $final_name ) {
284 296 continue;
285 297 }
@@ -297,11 +309,11 @@
297 309 // Field value.
298 310 $value = filter_input( INPUT_POST, $final_name, FILTER_DEFAULT );
299 311
300 312 // #1. Required validation.
301 - $is_required = ( 'yes' === $data['billing_list_required'] ) ? true : false;
313 + $is_required = ( ! empty( $data['billing_list_required'] ) && 'yes' === $data['billing_list_required'] ) ? true : false;
302 314
303 - if ( true === $is_required && empty( $final_name ) ) { // phpcs:ignore
315 + if ( true === $is_required && empty( $value ) ) { // phpcs:ignore
304 316 /* translators: %s field_name. */
305 317 wc_add_notice( sprintf( __( '%s is a required field.', 'sellkit' ), '<strong>' . $label . '</strong>' ), 'error' );
306 318 }
307 319
@@ -482,8 +494,9 @@
482 494 $item = [
483 495 'show_in_thank_you' => ( 'yes' === $data[ $type . '_show_in_thankyou' ] ) ? 'yes' : 'no',
484 496 'show_in_email' => ( 'yes' === $data[ $type . '_show_in_order_mail' ] ) ? 'yes' : 'no',
485 497 'key_name' => $final_name,
498 + 'label' => $data[ $type . '_list_placeholder' ],
486 499 ];
487 500
488 501 return $item;
489 502 }
@@ -505,11 +518,15 @@
505 518 unset( $default_fields['billing']['billing_email'] );
506 519
507 520 // Make it optional.
508 521 foreach ( $widget_billing_fields as $data ) {
509 - $slug = $data['billing_list_field'];
522 + $slug = isset( $data['billing_list_field'] ) ? $data['billing_list_field'] : '';
510 523 $is_required = false;
511 524
525 + if ( 'custom_role' === $slug ) {
526 + continue;
527 + }
528 +
512 529 if ( ! empty( $data['billing_list_required'] ) && 'yes' === $data['billing_list_required'] ) {
513 530 $is_required = true;
514 531 }
515 532
@@ -516,11 +533,15 @@
516 533 $default_fields['billing'][ $slug ]['required'] = $is_required;
517 534 }
518 535
519 536 foreach ( $widget_shipping_fields as $data ) {
520 - $slug = $data['shipping_list_field'];
537 + $slug = isset( $data['shipping_list_field'] ) ? $data['shipping_list_field'] : '';
521 538 $is_required = false;
522 539
540 + if ( 'custom_role' === $slug ) {
541 + continue;
542 + }
543 +
523 544 if ( ! empty( $data['shipping_list_required'] ) && 'yes' === $data['shipping_list_required'] ) {
524 545 $is_required = true;
525 546 }
526 547
@@ -705,6 +726,29 @@
705 726 $post['s_address_2'] = $clear['shipping_address_2'];
706 727 }
707 728
708 729 return $post;
730 + }
731 +
732 + /**
733 + * Check if product is in cart.
734 + *
735 + * @param int $product_id product id.
736 + * @since 1.7.4
737 + */
738 + public function is_product_in_cart( $product_id ) {
739 + // Get the WooCommerce cart.
740 + $cart = WC()->cart;
741 +
742 + foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {
743 + // Get the product ID for each cart item.
744 + $item_product_id = $cart_item['product_id'];
745 +
746 + // Check if the product ID matches the provided product ID.
747 + if ( $item_product_id === $product_id ) {
748 + return true;
749 + }
750 + }
751 +
752 + return false;
709 753 }
710 754 }