| 1 |
<?php |
| 2 |
|
| 3 |
namespace Booktics\Cart; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 6 |
|
| 7 |
use Booktics\Cart\Controllers\Cart_Controller; |
| 8 |
use Booktics\Providers\Base_Service_Provider; |
| 9 |
|
| 10 |
/** |
| 11 |
* Customer_Service_Provider will be responsible for all customer services |
| 12 |
* |
| 13 |
* @package Booktics/Customer |
| 14 |
*/ |
| 15 |
class Cart_Service_Provider extends Base_Service_Provider { |
| 16 |
/** |
| 17 |
* Store services |
| 18 |
* |
| 19 |
* @var array |
| 20 |
*/ |
| 21 |
protected $services = array( |
| 22 |
Cart_Controller::class, |
| 23 |
); |
| 24 |
|
| 25 |
/** |
| 26 |
* Register services |
| 27 |
* |
| 28 |
* @return void |
| 29 |
*/ |
| 30 |
public function get_services() { |
| 31 |
add_action( 'clear_auth_cookie', array( $this, 'clear_booktics_cart_on_logout' ) ); |
| 32 |
|
| 33 |
return apply_filters( 'booktics_cart_services', $this->services ); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Clear cart on logout |
| 38 |
* |
| 39 |
* @return void |
| 40 |
*/ |
| 41 |
public function clear_booktics_cart_on_logout() { |
| 42 |
( new Cart_Manager() )->remove_cart_item(); |
| 43 |
} |
| 44 |
} |
| 45 |
|