Skip to content

Instantly share code, notes, and snippets.

@maxout
Last active November 6, 2015 11:46
Show Gist options
  • Save maxout/c493eefc0bb80a287c4c to your computer and use it in GitHub Desktop.
Save maxout/c493eefc0bb80a287c4c to your computer and use it in GitHub Desktop.
Sprd:createBasket
<?php
/**
* Creates a new Spreadshirt basket
* @param $shop
* @param $namespaces
* @return array
*/
private function createBasket($shop, $namespaces)
{
$basket = new \SimpleXmlElement('<basket xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://api.spreadshirt.net">
<shop id="' . $this->Config->get('SHOP_ID') . '"/>
</basket>');
$attributes = $shop->baskets->attributes($namespaces['xlink']);
$basketsUrl = $attributes->href;
$result = $this->sendRequest($basketsUrl, 'POST', $basket);
if ($result) {
$basketUrl = $this->parseHttpHeaders($result, "Location");
} else {
die('ERROR: Oh, Basket not ready yet.');
}
return $basketUrl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment