activities_controller.php
11 months ago
auth_controller.php
9 months ago
booking_form_settings_controller.php
1 year ago
bookings_controller.php
1 year ago
calendars_controller.php
9 months ago
carts_controller.php
1 year ago
controller.php
9 months ago
customer_cabinet_controller.php
9 months ago
customers_controller.php
9 months ago
dashboard_controller.php
9 months ago
default_agent_controller.php
1 year ago
events_controller.php
1 year ago
form_fields_controller.php
9 months ago
integrations_controller.php
9 months ago
invoices_controller.php
1 year ago
manage_booking_by_key_controller.php
1 year ago
manage_order_by_key_controller.php
1 year ago
notifications_controller.php
1 year ago
orders_controller.php
1 year ago
pro_controller.php
1 year ago
process_jobs_controller.php
9 months ago
processes_controller.php
1 year ago
search_controller.php
1 year ago
services_controller.php
9 months ago
settings_controller.php
1 year ago
steps_controller.php
9 months ago
stripe_connect_controller.php
9 months ago
support_topics_controller.php
1 year ago
todos_controller.php
1 year ago
transactions_controller.php
1 year ago
wizard_controller.php
1 year ago
carts_controller.php
44 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 | $cart_item_id = $this->params['cart_item_id']; |
| 25 | $cart_item = new OsCartItemModel($cart_item_id); |
| 26 | $current_cart = OsCartsHelper::get_or_create_cart(); |
| 27 | if($current_cart->remove_item($cart_item)){ |
| 28 | $status = LATEPOINT_STATUS_SUCCESS; |
| 29 | $response_html = __('Booking removed from your cart', 'latepoint'); |
| 30 | }else{ |
| 31 | $status = LATEPOINT_STATUS_ERROR; |
| 32 | $response_html = __('Not Allowed', 'latepoint'); |
| 33 | } |
| 34 | if($this->get_return_format() == 'json'){ |
| 35 | $this->send_json(array('status' => $status, 'message' => $response_html)); |
| 36 | } |
| 37 | |
| 38 | } |
| 39 | |
| 40 | |
| 41 | } |
| 42 | |
| 43 | |
| 44 | endif; |