| 1 |
<?php |
| 2 |
|
| 3 |
namespace Sellkit\Funnel\Steps; |
| 4 |
|
| 5 |
use Sellkit_Funnel; |
| 6 |
|
| 7 |
defined( 'ABSPATH' ) || die(); |
| 8 |
|
| 9 |
/** |
| 10 |
* Class Decision. |
| 11 |
* |
| 12 |
* @since 1.5.0 |
| 13 |
*/ |
| 14 |
class Decision { |
| 15 |
|
| 16 |
/** |
| 17 |
* Decision constructor. |
| 18 |
* |
| 19 |
* @since 1.5.0 |
| 20 |
*/ |
| 21 |
public function __construct() { |
| 22 |
$this->funnel = Sellkit_Funnel::get_instance(); |
| 23 |
|
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Upsell actions. |
| 28 |
* |
| 29 |
* @since 1.1.0 |
| 30 |
* @SuppressWarnings(PHPMD.NPathComplexity) |
| 31 |
*/ |
| 32 |
public function do_actions() { |
| 33 |
$conditions = ! empty( $this->funnel->current_step_data['data']['conditions'] ) ? $this->funnel->current_step_data['data']['conditions'] : []; |
| 34 |
|
| 35 |
$is_valid = sellkit_conditions_validation( $conditions ); |
| 36 |
|
| 37 |
$args = []; |
| 38 |
|
| 39 |
if ( ! empty( $_GET['order-key'] ) ) { // phpcs:ignore |
| 40 |
$args['order-key'] = $_GET['order-key']; // phpcs:ignore |
| 41 |
} |
| 42 |
|
| 43 |
if ( $is_valid && ! empty( $this->funnel->next_step_data['page_id'] ) ) { |
| 44 |
wp_safe_redirect( add_query_arg( $args, get_permalink( $this->funnel->next_step_data['page_id'] ) ) ); |
| 45 |
return; |
| 46 |
} |
| 47 |
|
| 48 |
if ( ! $is_valid && ! empty( $this->funnel->next_no_step_data['page_id'] ) ) { |
| 49 |
wp_safe_redirect( add_query_arg( $args, get_permalink( $this->funnel->next_no_step_data['page_id'] ) ) ); |
| 50 |
return; |
| 51 |
} |
| 52 |
|
| 53 |
if ( ! empty( $this->funnel->end_node_step_data['page_id'] ) ) { |
| 54 |
wp_safe_redirect( add_query_arg( $args, get_permalink( $this->funnel->end_node_step_data['page_id'] ) ) ); |
| 55 |
} |
| 56 |
} |
| 57 |
} |
| 58 |
|