<?php

namespace Booktics\Cart;

if ( ! defined( 'ABSPATH' ) ) exit;

use Booktics\Cart\Controllers\Cart_Controller;
use Booktics\Providers\Base_Service_Provider;

/**
 * Customer_Service_Provider will be responsible for all customer services
 *
 * @package Booktics/Customer
 */
class Cart_Service_Provider extends Base_Service_Provider {
    /**
     * Store services
     *
     * @var array
     */
    protected $services = array(
        Cart_Controller::class,
    );

    /**
     * Register services
     *
     * @return  void
     */
    public function get_services() {
        add_action( 'clear_auth_cookie', array( $this, 'clear_booktics_cart_on_logout' ) );

        return apply_filters( 'booktics_cart_services', $this->services );
    }

    /**
     * Clear cart on logout
     *
     * @return void
     */
    public function clear_booktics_cart_on_logout() {
        ( new Cart_Manager() )->remove_cart_item();
    }
}
