obanana_b2b_test/cartitems.php

9 lines
310 B
PHP

<?php
include "functions.php";
$id = $_GET['id'];
$json = getOrderbyCustomerId($id);
$orders = json_decode($json, true);
$cartItems = array_filter($orders, function ($order) {
return isset($order['status']) && $order['status'] === 'CART' && isset($order['items'][0]['product']);
});
echo count($cartItems);