afosto / shopctrl
Afosto ShopCtrl client
Installs: 879
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 1
Type:package
Requires
- afosto/bp: ^2.0
- doctrine/inflector: v1.0.1
- guzzlehttp/guzzle: ^6.2
- psr/cache: ^2.0
Requires (Dev)
- filp/whoops: ^2
- symfony/console: ^3.2
- symfony/css-selector: ^3.2
- symfony/dom-crawler: ^3.2
- symfony/var-dumper: ^3.0
- dev-master
- 3.0.0
- 2.0.0
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.1
- 1.0.0
- 0.1.1
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- dev-Hotfix/invalid-validation-configuration
- dev-hotfix/send-invitation
- dev-hotfix/checksum
- dev-hotfix/exception-handling
This package is auto-updated.
Last update: 2024-11-28 13:05:26 UTC
README
Use this client to convieniently interact with ShopCtrl. This PHP package was developed by Afosto to make a reliable connection between Afosto (Retail Software) and ShopCtrl and provides the following functionality:
- get product data from ShopCtrl
- get order data from ShopCtrl
- create new orders at ShopCtrl
Getting Started
Simply follow the installation instructions. You will need an account at ShopCtrl that is set up for you to use.
Prerequisites
What things you need to install the software and how to install them
- PHP5.5+
- Composer (for installation)
Installing
Installing is easy through Composer.
composer require afosto/shopctrl
Examples
Now, to fetch productdata from ShopCtrl use the following code.
First set some configuration parameters:
$settings = new Settings();
Define the settings with data obtained from ShopCtrl
$settings->shopId = ''; $settings->baseUrl = ''; $settings->username = ''; $settings->password = ''; $settings->cultureId = '';
Initialze the application:
App::init($settings);
Get a product (from shop context)
Run a foreach for ProductSelections to get shop-context-related data and the full product that belongs to the productSelection data
foreach (ProductSelection::model()->findAll() as $productSelection) { $product = Product::model()->find($productSelection->productId); //Use the product data dump($productSelection, $product); }
Generate an order
To create an order use the following sample. First set the contact data.
$contact = new ContactInfo(); $contact->streetAddress = 'Grondzijl'; $contact->streetAddressNumber = 16; $contact->city = 'Groningen'; $contact->countryCode = 'NL'; $contact->companyName = 'Afosto SaaS BV'; $contact->eMail = 'peter@afosto.com'; $contact->firstName = 'Peter'; $contact->lastName = 'Bakker'; $contact->postalCode = '9731DG'; $contact->phone = '0507119519';
Create an order row.
$orderRow = new OrderRow(); $orderRow->orderRowKey = 1; $orderRow->itemQuantity = 1; $orderRow->productName = 'TestProduct'; $orderRow->productCode = 'ProductSku'; $orderRow->productDescription = 'Description test product'; $orderRow->itemPriceIncVat = 5.00; $orderRow->rowDiscountIncVat = 0; $orderRow->vatperc = 21; $orderRow->rowTotalIncVat = 5;
Create an order.
$order = new Order(); $order->id = 0; $order->shipToContact = $contact; $order->billToContact = $contact; $order->date = (new DateTime())->format('Y/m/d H:i:s'); $order->viewModusIncVAT = true; $order->paymentFeeIncVat = 0; $order->shippingCostsIncVat = 0; $order->customerNote = ''; $order->syncSource = 'Afosto'; $order->discountIncVat = 0; $order->orderRows[] = $orderRow; $order->orderCode = 'test' . time(); $order->orderTotalIncVat = 5.00; $order->currencyId = 1; $order->currencyCode = 'EUR';
Set some specific data for the order based on the context / settings
$order->paymentTypeId = App::getInstance()->getSettings()->getPaymentTypeId('iDeal'); $order->cultureId = App::getInstance()->getSetting('cultureId'); $order->shopId = App::getInstance()->getSetting('shopId'); $order->mainStatusId = App::getInstance()->getSettings()->getOrderStatus('Active');
Now create the order
$order->create();
Now use the new data (model is updated with the results from the server)
$order->id;
Other examples
In the examples directory you will find more examples of this project.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
License
This project is licensed under the Apache License 2.0 - see the LICENSE.md file for details