ID && 'enable' === $override_global_checkout ) { $edit_node = $wp_admin_bar->get_node( 'edit' ); if ( $edit_node ) { $edit_node->href = get_edit_post_link( $post->ID ); $wp_admin_bar->add_node( $edit_node ); } } } } /** * Override global checkout page * * @since 1.10.0 */ public function override_global_checkout() { if ( wcf()->utils->is_step_post_type() ) { return; } if ( is_product() || ! is_checkout() || is_order_received_page() || is_checkout_pay_page() ) { return; } // Return if the key OR Order parameter is found in the URL for certain Payment gateways. if ( isset( $_GET['key'] ) || isset( $_GET['order'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended return; } $common = Cartflows_Helper::get_common_settings(); $global_checkout = $common['global_checkout']; $override_global_checkout = $common['override_global_checkout']; // Override only WooCommerce checkout page with CartFlows checkout page. if ( ! empty( $global_checkout ) && 'enable' === $override_global_checkout ) { $checkout_post = get_post( $global_checkout ); if ( $checkout_post && 'publish' === $checkout_post->post_status ) { if ( isset( $GLOBALS['posts'][0] ) ) { $GLOBALS['posts'][0] = $checkout_post; //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited } if ( isset( $GLOBALS['wp_the_query']->post ) ) { $GLOBALS['wp_the_query']->post = $checkout_post; //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited } $GLOBALS['post'] = $checkout_post; //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited } } } /** * Redirect from default to the global checkout page * * @since 1.10.0 */ public function global_checkout_template_redirect() { if ( wcf()->utils->is_step_post_type() ) { return; } if ( is_product() || ! is_checkout() || is_order_received_page() || is_checkout_pay_page() ) { return; } // Return if the key OR Order parameter is found in the URL for certain Payment gateways. if ( isset( $_GET['key'] ) || isset( $_GET['order'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended return; } // redirect only for cartflows checkout pages. $common = Cartflows_Helper::get_common_settings(); $global_checkout = $common['global_checkout']; $override_global_checkout = $common['override_global_checkout']; if ( ! empty( $global_checkout ) && 'enable' !== $override_global_checkout ) { $link = apply_filters( 'cartflows_global_checkout_url', get_permalink( $global_checkout ) ); if ( ! empty( $link ) ) { wp_safe_redirect( $link ); exit; } } } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Global_Checkout::get_instance();