3

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."
1
  • Can we check if those items can be delivered to Australia or not? Commented Sep 28, 2017 at 12:00

2 Answers 2

2

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);
Sign up to request clarification or add additional context in comments.

1 Comment

Can we check if those items can be delivered to Australia or not?
0

I may be wrong, but I don't think your Item.1.ID should be part of another array. Try this instead:

$params = $this->buildRequestParams('CartCreate', array(
  'Item.1.ASIN' => $asin, 
  'Item.1.Quantity' => 1,
  'AssociateTag' => $associateTag,
));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.