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 +37 -3 1.6.52.7.0 View file →
@@ -90,9 +90,11 @@
90 90 public function get_user_defined_fields_slug( $user_defined_fields, $type ) {
91 91 $fields = [];
92 92
93 93 foreach ( $user_defined_fields as $field ) {
94 - $fields[] = $field[ $type ];
94 + if ( isset( $field[ $type ] ) ) {
95 + $fields[] = $field[ $type ];
96 + }
95 97 }
96 98
97 99 return $fields;
98 100 }
@@ -238,10 +240,13 @@
238 240 * @param array $shipping_fields custom shipping fields.
239 241 * @param array $billing_fields custom billing fields.
240 242 * @return void
241 243 * @since 1.1.0
244 + * @SuppressWarnings(PHPMD.CyclomaticComplexity)
242 245 */
243 246 public function validate_user_defined_fields( $shipping_fields, $billing_fields ) {
247 + $shipping_destination = get_option( 'woocommerce_ship_to_destination', true );
248 +
244 249 foreach ( $shipping_fields as $data ) {
245 250 // Escape all if cart does not need shipping information.
246 251 if ( ! WC()->cart->needs_shipping() ) {
247 252 continue;
@@ -246,8 +251,13 @@
246 251 if ( ! WC()->cart->needs_shipping() ) {
247 252 continue;
248 253 }
249 254
255 + // Escape all if shipping destination be billing only.
256 + if ( 'billing_only' === $shipping_destination ) {
257 + continue;
258 + }
259 +
250 260 $final_name = isset( $data['shipping_list_field'] ) ? $data['shipping_list_field'] : '';
251 261
252 262 if ( 'custom_role' === $final_name ) {
253 263 $final_name = 'shipping_' . $data['_id'];
@@ -279,9 +289,9 @@
279 289 $this->postcode_validation( $data, $final_name, 'shipping', $label );
280 290 }
281 291
282 292 foreach ( $billing_fields as $data ) {
283 - $final_name = $data['billing_list_field'];
293 + $final_name = isset( $data['billing_list_field'] ) ? $data['billing_list_field'] : '';
284 294
285 295 if ( 'custom_role' !== $final_name ) {
286 296 continue;
287 297 }
@@ -484,8 +494,9 @@
484 494 $item = [
485 495 'show_in_thank_you' => ( 'yes' === $data[ $type . '_show_in_thankyou' ] ) ? 'yes' : 'no',
486 496 'show_in_email' => ( 'yes' === $data[ $type . '_show_in_order_mail' ] ) ? 'yes' : 'no',
487 497 'key_name' => $final_name,
498 + 'label' => $data[ $type . '_list_placeholder' ],
488 499 ];
489 500
490 501 return $item;
491 502 }
@@ -507,9 +518,9 @@
507 518 unset( $default_fields['billing']['billing_email'] );
508 519
509 520 // Make it optional.
510 521 foreach ( $widget_billing_fields as $data ) {
511 - $slug = $data['billing_list_field'];
522 + $slug = isset( $data['billing_list_field'] ) ? $data['billing_list_field'] : '';
512 523 $is_required = false;
513 524
514 525 if ( 'custom_role' === $slug ) {
515 526 continue;
@@ -715,6 +726,29 @@
715 726 $post['s_address_2'] = $clear['shipping_address_2'];
716 727 }
717 728
718 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;
719 753 }
720 754 }