prestashop webservice add to cart removing old cart product

prestashop webservice add to cart removing old cart product

$xml = $webService->get(array('url' => 'https://myshop.com/api/carts?schema=blank'));
$xml->cart->id_customer = 74;
$xml->cart->id_address_delivery = 80;
$xml->cart->id_address_invoice = 80;
$xml->cart->id_currency = 2;
$xml->cart->id_lang = 1;
//$xml->cart->id_carrier = 12;
$xml->cart->secure_key = 'xxxxxxxx';
$xml->cart->id_shop_group =1;
$xml->cart->associations->cart_rows->cart_row->id_product = 5743;
$xml->cart->associations->cart_rows->cart_row->quantity = 1;
$xml->cart->associations->cart_rows->cart_row->id_address_delivery = 80;
$xml->cart->associations->cart_rows->cart_row->id_shop = 1;
$xml->cart->associations->cart_rows->cart_row->id_product_attribute = 22983;

$opt = array('resource' => 'carts');
$opt['postXml'] = $xml->asXML();

$xml = $webService->get(array('url' => 'https://myshop.com/api/carts?schema=blank'));
$xml->cart->id_customer = 74;
$xml->cart->id_address_delivery = 80;
$xml->cart->id_address_invoice = 80;
$xml->cart->id_currency = 2;
$xml->cart->id_lang = 1;
//$xml->cart->id_carrier = 12;
$xml->cart->secure_key = 'xxxxxxxx';
$xml->cart->id_shop_group =1;
$xml->cart->associations->cart_rows->cart_row->id_product = 5743;
$xml->cart->associations->cart_rows->cart_row->quantity = 1;
$xml->cart->associations->cart_rows->cart_row->id_address_delivery = 80;
$xml->cart->associations->cart_rows->cart_row->id_shop = 1;
$xml->cart->associations->cart_rows->cart_row->id_product_attribute = 22983;

$opt = array('resource' => 'carts');
$opt['postXml'] = $xml->asXML();

$webService->add($opt);