setItemQuantity not working with PHP library
The setItemQuantity method does not seem to be working with the PHP library. How are we supposed to specify the itemCode?
The error:
Fatal error: Uncaught exception
'CheddarGetter_Response_Exception' with message 'An itemId or
itemCode is required' in Response.php:316
The API method from the PHP library:
/**
* Set a usage item quantity
*
* @param string $code Your code for the customer
* @param string|null $id CG id for the customer
* @param array $data Your (itemCode or CG itemId) and quantity
* @return CheddarGetter_Response
* @throws CheddarGetter_Response_Exception
*/
public function setItemQuantity($code, $id = null, array $data) {
$this->_requireIdentifier($code, $id);
return new CheddarGetter_Response(
$this->request(
'/customers/set-item-quantity/' . (($id) ? 'id/'.$id : 'code/'.$code),
$data
)
);
}
The API docs are here: https://cheddargetter.com/developers#set-item-quantity
I don't see how "itemCode" even has a chance to get into the URL
with this code, but maybe I'm calling it wrong or misreading. I
think this is how we're supposed to call it based on the
method docs, right?
$client->setItemQuantity($custcode, NULL, array('quantity'
=> $quantity));
But how do we provide itemCode exactly? The $data description
hints at it, but from the API docs, all we're supposed to post is
quantity=12345... I tried this too and it didn't work:
$client->setItemQuantity($custcode, NULL,
array('MYITEMCODE' => $quantity));
Please explain and provide a one-line example of how to use this method. Thank you!
P.S. The same applies for addItemQuantity, etc.
Discussions are closed to public comments.
If you need help with Cheddar please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Marc Guyer on 06 May, 2010 10:47 PM
Ahh, there does appear to be a discrepancy between the API doc and the PHP wrapper. The
customers/set-item-quantity
call can accept parameters in two ways. The first is documented in the API docs. The second is what the PHP wrapper is expecting but it's not documented. For the PHP wrapper:The same goes for
customers/add-item-quantity
2 Posted by Dan Kamins on 07 May, 2010 12:07 AM
Great, thank you -- this is working now. Is there by any chance an undocumented way to set more than one tracked item in a single API call?
Support Staff 3 Posted by Marc Guyer on 07 May, 2010 12:13 AM
There isn't but that's an interesting thought. I wonder how often that
would be useful.
4 Posted by Dan Kamins on 07 May, 2010 12:23 AM
Started a new suggestion thread to close this one / track the suggestion separately:
http://support.cheddargetter.com/discussions/suggestions/36-allow-u...
Support Staff 5 Posted by Marc Guyer on 07 May, 2010 03:13 PM
Thanks for starting the new thread!
Marc Guyer closed this discussion on 07 May, 2010 03:13 PM.