I am trying to add cart functions to the AmazonECS class available at https://github.com/Exeu/Amazon-ECS-PHP-Library
The main class of that project is https://github.com/Exeu/Amazon-ECS-PHP-Library/blob/master/lib/AmazonECS.class.php
It currently supports ItemLookup and ItemSearch but it does not have CartCreate, CartClear, CartAdd, CartGet, CartModify.
Amazon's documentation about these API calls can be found on this page http://docs.aws.amazon.com/AWSECommerceService/2011-08-01/DG/CartCreate.html
Here's one of the things I have tried which hasn't worked.
/**
* execute CartCreate request
*
* @param string $asin, $associateTag
*
* @return array|object return type depends on setting
*
* @see returnType()
*/
public function cartCreate($asin, $associateTag)
{
$params = $this->buildRequestParams('CartCreate', array(
array('Item.1.ASIN' => $asin, 'Item.1.Quantity' => 1),
'AssociateTag' => $associateTag,
));
return $this->returnData($this->performSoapRequest("CartCreate", $params));
}
Does anyone know what I'm doing wrong? The error message I get back from that call is
string(79) "Your request is missing required parameters. Required parameters include Items."
For anyone who is still searching for an answer to this, I have this solution for you. The following is my cart function:
public function CartCreate($OfferListingId)
{
$params = $this->buildRequestParams('CartCreate', array(
'Items' => array(
'Item' => array(
//You can also use 'ASIN' here
'OfferListingId' => $OfferListingId,
'Quantity' => 1,
)
)
));
return $this->returnData(
$this->performSoapRequest("CartCreate", $params)
);
}
The parameters you send should be constructed as an associated array.
Also, in case you get an error about not being able to add the item with ASIN to the cart, remember to add the country code to the Request, since the default is US and, for example, in my case I needed items from UK. This is how I do my Request:
$cart = $this->ecs->country('UK')->ResponseGroup('Cart')->CartCreate($OfferListingId);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With