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/admin/settings/integration/class.php +92 -2 1.5.72.7.0 View file →
@@ -3,8 +3,10 @@
3 3 namespace Sellkit\Admin\Settings\Integration;
4 4
5 5 defined( 'ABSPATH' ) || die();
6 6
7 +use Sellkit\Global_Checkout\Checkout as Global_Checkout;
8 +
7 9 /**
8 10 * Class Google Analytics and Facebook Pixel integration.
9 11 *
10 12 * @package Sellkit\Admin\Settings\Integration\Settings_Integration
@@ -73,19 +75,25 @@
73 75 */
74 76 public function google_facebook_analytics() {
75 77 global $post;
76 78
79 + $step_meta = $this->get_step_meta( $post );
80 +
77 81 if (
78 82 empty( $post ) ||
79 - empty( get_post_meta( $post->ID, 'step_data' ) ) ||
83 + empty( $step_meta ) ||
80 84 $this->is_elementor_preview()
81 85 ) {
82 86 return;
83 87 }
84 88
85 - self::$post = get_post_meta( $post->ID, 'step_data' );
89 + self::$post = $step_meta;
86 90 self::$order_key = sellkit_htmlspecialchars( INPUT_GET, 'order-key' );
87 91
92 + if ( empty( self::$order_key ) ) {
93 + self::$order_key = sellkit_htmlspecialchars( INPUT_GET, 'key' );
94 + }
95 +
88 96 if ( ! sellkit()->has_valid_dependencies() ) {
89 97 self::$order_key = null;
90 98 }
91 99
@@ -96,8 +104,90 @@
96 104 ]
97 105 );
98 106
99 107 wp_localize_script( 'funnel-settings-variables', 'sellkitSettings', self::$localized_data );
108 + }
109 +
110 + /**
111 + * Get step meta.
112 + *
113 + * @param object $post post object.
114 + * @since 2.3.0
115 + * @return array|void
116 + */
117 + private function get_step_meta( $post ) {
118 + if ( empty( $post ) ) {
119 + return;
120 + }
121 +
122 + $step_meta = get_post_meta( $post->ID, 'step_data' );
123 +
124 + if ( ! empty( $step_meta ) ) {
125 + return $step_meta;
126 + }
127 +
128 + $global_checkout_id = get_option( Global_Checkout::SELLKIT_GLOBAL_CHECKOUT_OPTION, 0 );
129 +
130 + if ( empty( $global_checkout_id ) ) {
131 + return;
132 + }
133 +
134 + if ( 'publish' !== get_post_status( $global_checkout_id ) ) {
135 + return;
136 + }
137 +
138 + $global_chekout_nodes = get_post_meta( $global_checkout_id, 'nodes' );
139 +
140 + if ( empty( $global_chekout_nodes ) ) {
141 + return;
142 + }
143 +
144 + $global_chekout_nodes = $global_chekout_nodes[0];
145 + $global_chekout_nodes = $this->check_global_checkout_steps( $global_chekout_nodes, $post->ID );
146 +
147 + if ( empty( $global_chekout_nodes ) ) {
148 + return;
149 + }
150 +
151 + return $global_chekout_nodes;
152 + }
153 +
154 + /**
155 + * Check global checkout steps.
156 + *
157 + * @param array $global_chekout_nodes global checkout nodes.
158 + * @param int $post_id post id.
159 + * @since 2.3.0
160 + * @return array
161 + */
162 + private function check_global_checkout_steps( $global_chekout_nodes, $post_id ) {
163 + $default_checkout_page = intval( get_option( 'woocommerce_checkout_page_id', 0 ) );
164 + $default_thankyou_page = is_checkout() && ! empty( is_wc_endpoint_url( 'order-received' ) );
165 + $is_checkout_page = is_checkout() && empty( is_wc_endpoint_url( 'order-received' ) );
166 +
167 + $new_nodes = [];
168 +
169 + if ( $default_checkout_page !== $post_id && $default_thankyou_page ) {
170 + return [];
171 + }
172 +
173 + foreach ( $global_chekout_nodes as $node ) {
174 + if ( 'checkout' === $node['type']['key'] && ! empty( $default_checkout_page ) && $is_checkout_page ) {
175 + $new_nodes[ $default_checkout_page ] = $node;
176 + continue;
177 + }
178 +
179 + if ( 'thankyou' === $node['type']['key'] && ! empty( $default_thankyou_page ) ) {
180 + $new_nodes[ $post_id ] = $node;
181 + continue;
182 + }
183 + }
184 +
185 + if ( ! isset( $new_nodes[ $post_id ] ) ) {
186 + return [];
187 + }
188 +
189 + return $new_nodes;
100 190 }
101 191
102 192 /**
103 193 * Check is elementor preview.