activities_controller.php
1 month ago
auth_controller.php
3 months ago
booking_form_settings_controller.php
3 months ago
bookings_controller.php
17 hours ago
calendars_controller.php
3 months ago
carts_controller.php
17 hours ago
controller.php
3 months ago
customer_cabinet_controller.php
2 months ago
customers_controller.php
17 hours ago
dashboard_controller.php
2 months ago
default_agent_controller.php
3 months ago
events_controller.php
3 months ago
form_fields_controller.php
1 week ago
integrations_controller.php
3 months ago
invoices_controller.php
17 hours ago
manage_booking_by_key_controller.php
3 months ago
manage_order_by_key_controller.php
3 months ago
notifications_controller.php
3 months ago
orders_controller.php
17 hours ago
pro_controller.php
2 weeks ago
process_jobs_controller.php
3 months ago
processes_controller.php
1 month ago
razorpay_connect_controller.php
1 week ago
search_controller.php
3 months ago
services_controller.php
3 months ago
settings_controller.php
2 months ago
steps_controller.php
2 weeks ago
stripe_connect_controller.php
1 week ago
support_topics_controller.php
3 months ago
todos_controller.php
3 months ago
transactions_controller.php
17 hours ago
wizard_controller.php
1 week ago
carts_controller.php
48 lines
| 1 | <?php |
| 2 | /* |
| 3 | * Copyright (c) 2023 LatePoint LLC. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | exit; // Exit if accessed directly. |
| 8 | } |
| 9 | |
| 10 | |
| 11 | if ( ! class_exists( 'OsCartsController' ) ) : |
| 12 | |
| 13 | |
| 14 | class OsCartsController extends OsController { |
| 15 | |
| 16 | function __construct() { |
| 17 | parent::__construct(); |
| 18 | $this->views_folder = LATEPOINT_VIEWS_ABSPATH . 'carts/'; |
| 19 | |
| 20 | $this->action_access['public'] = array_merge( $this->action_access['public'], [ 'remove_item_from_cart' ] ); |
| 21 | } |
| 22 | |
| 23 | public function remove_item_from_cart() { |
| 24 | $this->check_nonce( 'remove_item_from_cart' ); |
| 25 | $cart_item_id = $this->params['cart_item_id']; |
| 26 | $cart_item = new OsCartItemModel( $cart_item_id ); |
| 27 | $current_cart = OsCartsHelper::get_or_create_cart(); |
| 28 | if ( $current_cart->remove_item( $cart_item ) ) { |
| 29 | $status = LATEPOINT_STATUS_SUCCESS; |
| 30 | $response_html = __( 'Booking removed from your cart', 'latepoint' ); |
| 31 | } else { |
| 32 | $status = LATEPOINT_STATUS_ERROR; |
| 33 | $response_html = __( 'Not Allowed', 'latepoint' ); |
| 34 | } |
| 35 | if ( $this->get_return_format() == 'json' ) { |
| 36 | $this->send_json( |
| 37 | array( |
| 38 | 'status' => $status, |
| 39 | 'message' => $response_html, |
| 40 | ) |
| 41 | ); |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | |
| 47 | endif; |
| 48 |