<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Support\Facades\Auth;
use Tymon\JWTAuth\Facades\JWTAuth;
class AddCustomHeaders
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next)
{
$request->headers->add([
'Accept' => 'application/json',
'Content-Type' => 'application/x-www-form-urlencoded',
]);
if ($request->token) {
$request->headers->add([
'Authorization' => $request->token,
]);
}
return $next($request);
}
}
add_action("wp_ajax_remove_item", "remove_item");
add_action("wp_ajax_nopriv_remove_item", "remove_item");
function remove_item()
{
$cart_item_data = $_POST["product_id"];
global $woocommerce;
$baskets = WC()->cart->get_cart();
WC()->cart->remove_cart_item($_POST["product_id"]);
wp_die();
}