Craft 3
This is how Craft Commerce fetches the Card
if ($orderNumber = $request->getBodyParam('orderNumber')) {
// Get the cart from the order number
$cart = Order::find()->number($orderNumber)->isCompleted(false)->one();
}
You have to include an orderNumber
parameter
Craft 2
$number = $this->_getSessionCartNumber();
if ($cart = $this->_getCartRecordByNumber($number))
{
$this->_cart = Commerce_OrderModel::populateModel($cart);
}
else
{
$this->_cart = new Commerce_OrderModel;
$this->_cart->number = $number;
}
/**
* @return mixed|string
*/
private function _getSessionCartNumber()
{
$cookieId = $this->cookieCartId;
$cartNumber = craft()->userSession->getStateCookieValue($cookieId);
if (!$cartNumber)
{
$cartNumber = md5(uniqid(mt_rand(), true));
$configInterval = craft()->config->get('cartCookieDuration', 'commerce');
$interval = new DateInterval($configInterval);
$cartExpiry = date_create('@0')->add($interval)->getTimestamp();
craft()->userSession->saveCookie($cookieId, $cartNumber, $cartExpiry);
}
return $cartNumber;
}
I think you'll have to change the cookie
credentials: 'same-origin',
to the fetch object.