PHP code example of jacobdekeizer / ccvshop-client
1. Go to this page and download the library: Download jacobdekeizer/ccvshop-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jacobdekeizer / ccvshop-client example snippets
$client = new \JacobDeKeizer\Ccv\Client();
$client->setBaseUrl('https://demo.ccvshop.nl');
$client->setPublicKey('public_key');
$client->setPrivateKey('private_key');
$result = $client->root()->all();
foreach ($result->getItems() as $item) {
var_dump($item);
}
$parameters = (new \JacobDeKeizer\Ccv\Parameters\Apps\AllFromAppstorecategory())
->setName('FooBar')
->expandCategories()
->orderByDateAsc();
$apps = $client->apps()->allFromAppstorecategory(11, $parameters);
foreach ($apps->getItems() as $app) {
var_dump($app->getName());
}
$apps = $client->apps()->all();
foreach ($apps->getItems() as $app) {
var_dump($app->getName());
}
$client->categories()->create(
(new \JacobDeKeizer\Ccv\Models\Internal\Resource\Categories\Post\Post())
->setName('foo bar')
);
$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Categories\Patch\Patch())
->setName('foo bar');
$client->categories()->update(1, $patch);
$client->categories()->delete(12345);
// see the code and documentation for all available methods
$getInvoicesParameter = (new \JacobDeKeizer\Ccv\Parameters\Invoices\All)
->setMinCreateDate('2020-01-01')
->setMaxCreateDate('2020-01-31');
$invoices = $client->invoices()->all($getInvoicesParameter);
$invoice = $client->invoices()->get(123456);
$invoice = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Invoices\Input\Input())
->setStatus(1);
// ->set...
$client->invoices()->update(123456, $invoice);
$invoice = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Invoices\Input\Input())
->setStatus(2);
//->set..
$client->invoices()->createForOrder(123, $invoice);
$getOrdersParameter = (new \JacobDeKeizer\Ccv\Parameters\Orders\All)
->setStatus(1)
->setIsPaid(true)
->setIsCompleted(true);
do {
$orders = $client->orders()->all($getOrdersParameter);
foreach ($orders->getItems() as $order) {
// see the code and documentation for all available methods
var_dump($order);
$order->getUser()->getId();
$order->getCustomer()->getBillingaddress()->getStreet();
$order->getCustomer()->getBillingaddress()->getHousenumber();
$order->getCustomer()->getBillingaddress()->getHousenumberSuffix();
$order->getCustomer()->getBillingaddress()->getZipcode();
$order->getCustomer()->getBillingaddress()->getCity();
$order->getCustomer()->getDeliveryaddress()->getStreet();
$order->getCustomer()->getDeliveryaddress()->getHousenumber();
$order->getCustomer()->getDeliveryaddress()->getHousenumberSuffix();
$order->getCustomer()->getDeliveryaddress()->getZipcode();
$order->getCustomer()->getDeliveryaddress()->getCity();
$order->getCustomer()->getBillingaddress()->getFirstName();
$order->getCustomer()->getBillingaddress()->getLastName();
$order->getCustomer()->getBillingaddress()->getTelephone();
$order->getCustomer()->getEmail();
$orderRows = $client->orderrows()->allFromOrder($order->getId());
var_dump($orderRows);
foreach ($orderRows->getItems() as $orderRow) {
var_dump($orderRow);
$orderRow->getId();
$orderRow->getCount();
$orderRow->getPrice();
$orderRow->getProductId();
$orderRow->getProductName();
$orderRow->getPriceWithoutDiscount();
$orderRow->getDiscount();
$orderRow->getStockLocation();
$orderRow->getWeight();
$orderRow->getSubEanNumber();
}
}
$getOrdersParameter = \JacobDeKeizer\Ccv\Parameters\Orders\All::fromUrl($orders->getNext());
} while($getOrdersParameter !== null);
// see the code and documentation for all available methods
$order = $client->orders()->get(123456);
$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Orders\Patch\Patch())
->setStatus(6)
->setCustomer(
(new \JacobDeKeizer\Ccv\Models\Internal\Entity\Personalinfo\Input\Input())
->setEmail('[email protected]')
);
// ->set...
$client->orders()->update(123456, $patch);
$order = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Orders\Post\Post())
->setInvoicenumber(123456);
//->set..
$client->orders()->create($order);
$ordernote = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Ordernotes\Post\Post())
->setNote('this note will not be seen by the customer');
$client->ordernotes()->createForOrder(123, $ordernote);
$ordernotification = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Ordernotifications\Input\Input())
->setType('customer_paymentlink');
$client->ordernotifications()->createForOrder(123, $ordernotification);
$packages = $client->packages()->all();
$package = $client->packages()->get(12345);
$client->packages()->create(
(new \JacobDeKeizer\Ccv\Models\Internal\Resource\Packages\Input\Input())
->setName('foobar')
);
$input = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Packages\Input\Input())
->setName('baz boo');
$client->packages()->update(12345, $input);
// parameter is optional
$getProductsParameter = (new \JacobDeKeizer\Ccv\Parameters\Products\All)
->setMinStock(5)
->expandProductPhotos()
->orderByIdAsc();
$products = $client->products()->all($getProductsParameter);
foreach ($products->getItems() as $product) {
// see the code and documentation for all available methods
var_dump($product);
$product->getId();
$product->getStock();
$product->getDiscount();
$product->getWeight();
$product->getPrice();
$product->getBrand()->getId();
$product->getEannumber();
$product->getVatrate();
// ...
}
$nextRequest = \JacobDeKeizer\Ccv\Parameters\Products\All::fromUrl($products->getNext());
// see the code and documentation for all available methods
$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Products\Patch\Patch())
->setDiscount(4.99)
->setPrice(100)
->setProductnumber('my_number')
->setActive(true)
->setDescription('This is a description')
->setEannumber('an ean number')
->setMetaKeywords('keyword')
->setStock(100)
->setUnit('piece')
->setWeight(5.5);
$client->products()->update(1234, $patch);
// or only update stock
$client->products()->update(
1234,
(new \JacobDeKeizer\Ccv\Models\Internal\Resource\Products\Patch\Patch())
->setStock(99)
);
// see the code and documentation for all available methods
$product = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Products\Post\Post())
->setDiscount(4.99)
->setPrice(100)
->setProductnumber('my_number')
->setActive(true)
->setDescription('This is a description')
->setEannumber('an ean number')
->setMetaKeywords('keyword')
->setStock(100)
->setUnit('piece')
->setWeight(5.5);
// ->set...
$client->products()->create($product);
$post = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productattributevalues\Post\Post())
->setPrice(2);
// ->set...
$client->productattributevalues()->createForProduct(1234, $post);
$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productattributevalues\Patch\Patch())
->setPrice(2);
// ->set...
$client->productattributevalues()->update(1234, $patch);
$client->productattributevalues()->delete(1234);
$client->productphotos()->get(1234);
$client->productphotos()->delete(1234);
$client->productphotos()->allFromProduct(1234);
$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productphotos\Patch\Patch())
->setAlttext('text')
->setIsMainphoto(true);
$client->productphotos()->update(1234, $patch);
// see the code and documentation for all available methods
$post = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productphotos\Post\Post())
->setSource(base64_encode(file_get_contents('photo.png')))
->setFileType('png');
// ->set...
$client->productphotos()->createForProduct(1234, $post);
// see the code and documentation for all available methods
$productPhoto1 = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productphotos\Post\Post())
->setSource(base64_encode(file_get_contents('photo1.png')))
->setFileType('png');
// ->set...
$productPhoto2 = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productphotos\Post\Post())
->setSource(base64_encode(file_get_contents('photo2.jpg')))
->setFileType('jpg');
// ->set...
$put = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productphotos\Put\Put)
->setProductphotos($productPhoto1, $productPhoto2);
$client->productphotos()->updateForProduct(1234, $put);
$post = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Producttocategories\Post\Post())
->setProductId(123)
->setCategoryId(456)
->setPosition(null);
$client->producttocategories()->create($post);