*/ public static function get_handled_query_args(): array { return [ 'add-to-cart', 'product_id', 'quantity', 'variation_id', 'ips_order_bump_id', 'ips_order_bump_location', ]; } public static function is_enabled(): bool { if ( is_admin() || ! function_exists( 'WC' ) ) { return false; } return AddToCartRuntimePolicy::should_boot_bridge(); } public static function should_render_runtime(): bool { if ( ! self::is_enabled() ) { return false; } return ! is_checkout() && ! is_order_received_page() && ! is_checkout_pay_page(); } public static function should_prevent_native_redirects(): bool { return self::is_enabled() && ! wp_doing_ajax(); } public static function is_sidecart_ajax_request(): bool { if ( ! wp_doing_ajax() ) { return false; } $wc_ajax = isset( $_GET['wc-ajax'] ) ? sanitize_key( wp_unslash( $_GET['wc-ajax'] ) ) : ''; return 'ipscmi_order_cart_add_to_cart' === $wc_ajax; } public static function is_get_add_to_cart_request(): bool { if ( 'GET' !== strtoupper( (string) ( $_SERVER['REQUEST_METHOD'] ?? '' ) ) ) { return false; } return self::get_requested_product_id() > 0; } public static function get_requested_product_id(): int { $product_id = is_scalar( $_REQUEST[ self::get_internal_product_id_key() ] ?? null ) ? absint( wp_unslash( $_REQUEST[ self::get_internal_product_id_key() ] ) ) : 0; if ( $product_id <= 0 ) { $product_id = is_scalar( $_REQUEST['product_id'] ?? null ) ? absint( wp_unslash( $_REQUEST['product_id'] ) ) : 0; } if ( $product_id <= 0 ) { $product_id = is_scalar( $_REQUEST['add-to-cart'] ?? null ) ? absint( wp_unslash( $_REQUEST['add-to-cart'] ) ) : 0; } return $product_id; } public static function get_clean_request_url(): string { $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? (string) wp_unslash( $_SERVER['REQUEST_URI'] ) : ''; if ( '' === $request_uri ) { return ''; } $query_args = self::get_handled_query_args(); foreach ( array_keys( $_GET ) as $key ) { if ( 0 === strpos( (string) $key, 'attribute_' ) ) { $query_args[] = (string) $key; } } return (string) remove_query_arg( array_unique( $query_args ), $request_uri ); } }