Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php on line 107

Warning: Cannot modify header information - headers already sent by (output started at /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php:1) in /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php on line 234

Warning: Cannot modify header information - headers already sent by (output started at /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php:1) in /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php on line 235

Warning: Cannot modify header information - headers already sent by (output started at /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php:1) in /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php on line 236

Warning: Cannot modify header information - headers already sent by (output started at /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php:1) in /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php on line 237

Warning: Cannot modify header information - headers already sent by (output started at /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php:1) in /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php on line 238

Warning: Cannot modify header information - headers already sent by (output started at /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php:1) in /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php on line 239
model = new CartModel(); if ( $register_hooks ) { /** * Handle AJAX request for adding course to cart * * @since 3.0.0 */ add_action( 'wp_ajax_tutor_add_course_to_cart', array( $this, 'add_course_to_cart' ) ); /** * Handle AJAX request for deleting course from cart * * @since 3.0.0 */ add_action( 'wp_ajax_tutor_delete_course_from_cart', array( $this, 'delete_course_from_cart' ) ); } } /** * Create cart page * * @since 3.0.0 * * @return void */ public static function create_cart_page() { $page_id = self::get_page_id(); if ( ! $page_id ) { $args = array( 'post_title' => ucfirst( self::PAGE_SLUG ), 'post_content' => '', 'post_type' => 'page', 'post_status' => 'publish', ); $page_id = wp_insert_post( $args ); tutor_utils()->update_option( self::PAGE_ID_OPTION_NAME, $page_id ); } } /** * Get cart page url * * @since 3.0.0 * * @return string */ public static function get_page_url() { return get_post_permalink( self::get_page_id() ); } /** * Get cart page ID * * @since 3.0.0 * * @return string */ public static function get_page_id() { return (int) tutor_utils()->get_option( self::PAGE_ID_OPTION_NAME ); } /** * Get cart items * * @since 3.0.0 * * @return array */ public function get_cart_items() { $user_id = tutils()->get_user_id(); return $this->model->get_cart_items( $user_id ); } /** * Get cart count. * * @since 3.0.0 * * @param int $user_id logged in user_id. * * @return int */ public function get_user_cart_item_count( $user_id = 0 ) { if ( ! $user_id ) { $user_id = tutils()->get_user_id(); } $cart_items = $this->model->get_cart_items( $user_id ); $cart_count = $cart_items['courses']['total_count']; return $cart_count; } /** * Add course to cart * * @since 3.0.0 * * @return void JSON response */ public function add_course_to_cart() { if ( ! tutor_utils()->is_nonce_verified() ) { $this->json_response( tutor_utils()->error_message( 'nonce' ), null, HttpHelper::STATUS_BAD_REQUEST ); } $user_id = tutils()->get_user_id(); $course_id = Input::post( 'course_id', 0, Input::TYPE_INT ); if ( ! $course_id ) { $this->json_response( __( 'Invalid course id.', 'tutor' ), null, HttpHelper::STATUS_BAD_REQUEST ); } // Check if the course already exists in the cart or not. $is_course_in_user_cart = $this->model->is_course_in_user_cart( $user_id, $course_id ); if ( $is_course_in_user_cart ) { $this->json_response( __( 'The course is already in the cart.', 'tutor' ), null, HttpHelper::STATUS_BAD_REQUEST ); } $response = $this->model->add_course_to_cart( $user_id, $course_id ); if ( $response ) { $this->json_response( __( 'The course was added to the cart successfully.', 'tutor' ), array( 'cart_page_url' => self::get_page_url(), 'cart_count' => self::get_user_cart_item_count( $user_id ), ), HttpHelper::STATUS_CREATED ); } else { $this->json_response( __( 'Failed to add to cart.', 'tutor' ), null, HttpHelper::STATUS_BAD_REQUEST ); } } /** * Delete course from cart * * @since 3.0.0 * * @return void JSON response */ public function delete_course_from_cart() { if ( ! tutor_utils()->is_nonce_verified() ) { $this->json_response( tutor_utils()->error_message( 'nonce' ), null, HttpHelper::STATUS_BAD_REQUEST ); } $user_id = tutils()->get_user_id(); $course_id = Input::post( 'course_id', 0, Input::TYPE_INT ); if ( ! $course_id ) { $this->json_response( __( 'Invalid course id.', 'tutor' ), null, HttpHelper::STATUS_BAD_REQUEST ); } $response = $this->model->delete_course_from_cart( $user_id, $course_id ); if ( $response ) { ob_start(); tutor_load_template( 'ecommerce.cart' ); $cart_template = ob_get_clean(); $data = array( 'cart_template' => $cart_template, 'cart_count' => self::get_user_cart_item_count( $user_id ), ); $this->json_response( __( 'The course was removed successfully.', 'tutor' ), $data, HttpHelper::STATUS_OK ); } else { $this->json_response( __( 'Course remove failed.', 'tutor' ), null, HttpHelper::STATUS_BAD_REQUEST ); } } }