PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.3.0
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.3.0
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
← All changes | abilities/class-cartflows-ability-runtime.php +33 -10 3.1.3 → 3.3.0 View file →
@@ -2504,13 +2504,14 @@
2504 2504 $flow_title = get_the_title( $flow_id );
2505 2505 }
2506 2506
2507 2507 return array(
2508 - 'product_id' => intval( $product_id ),
2509 - 'product_title' => esc_html( $product->get_name() ),
2510 - 'flow_id' => $flow_id,
2511 - 'flow_title' => esc_html( $flow_title ),
2512 - 'add_to_cart_text' => esc_html( wp_unslash( $add_to_cart_text ) ),
2508 + 'product_id' => intval( $product_id ),
2509 + 'product_title' => esc_html( $product->get_name() ),
2510 + 'flow_id' => $flow_id,
2511 + 'flow_title' => esc_html( $flow_title ),
2512 + 'add_to_cart_text' => esc_html( wp_unslash( $add_to_cart_text ) ),
2513 + 'redirect_add_to_cart' => $this->product_redirects_to_flow( $product, $flow_id ),
2513 2514 );
2514 2515
2515 2516 } catch ( \Exception $e ) {
2516 2517 return $this->error( $e );
@@ -2569,13 +2570,14 @@
2569 2570 $flow_title = get_the_title( $flow_id );
2570 2571 }
2571 2572
2572 2573 $mappings[] = array(
2573 - 'product_id' => intval( $pid ),
2574 - 'product_title' => esc_html( $product->get_name() ),
2575 - 'flow_id' => $flow_id,
2576 - 'flow_title' => esc_html( $flow_title ),
2577 - 'add_to_cart_text' => esc_html( wp_unslash( $product->get_meta( 'cartflows_add_to_cart_text' ) ) ),
2574 + 'product_id' => intval( $pid ),
2575 + 'product_title' => esc_html( $product->get_name() ),
2576 + 'flow_id' => $flow_id,
2577 + 'flow_title' => esc_html( $flow_title ),
2578 + 'add_to_cart_text' => esc_html( wp_unslash( $product->get_meta( 'cartflows_add_to_cart_text' ) ) ),
2579 + 'redirect_add_to_cart' => $this->product_redirects_to_flow( $product, $flow_id ),
2578 2580 );
2579 2581 }
2580 2582 }
2581 2583
@@ -2591,8 +2593,29 @@
2591 2593
2592 2594 } catch ( \Exception $e ) {
2593 2595 return $this->error( $e );
2594 2596 }
2597 + }
2598 +
2599 + /**
2600 + * Whether Add to Cart on this product will redirect into its mapped flow.
2601 + *
2602 + * Mirrors the conditions in Cartflows_Wd_Flow_Product_Actions::redirect_to_next_flow_step().
2603 + *
2604 + * @since x.x.x
2605 + * @param \WC_Product $product Product.
2606 + * @param int $flow_id Mapped flow ID.
2607 + * @return bool
2608 + */
2609 + private function product_redirects_to_flow( $product, $flow_id ) {
2610 +
2611 + if ( empty( $flow_id ) || 'publish' !== get_post_status( $flow_id ) || 'no' === $product->get_meta( 'cartflows_redirect_add_to_cart' ) ) {
2612 + return false;
2613 + }
2614 +
2615 + $steps = get_post_meta( $flow_id, 'wcf-steps', true );
2616 +
2617 + return is_array( $steps ) && ! empty( $steps[0]['id'] );
2595 2618 }
2596 2619
2597 2620 /**
2598 2621 * Update flow mapping on a WooCommerce product.