afosto/shopctrl 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

afosto/shopctrl

最新稳定版本:3.0.1

Composer 安装命令:

composer require afosto/shopctrl

包简介

Afosto ShopCtrl client

README 文档

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

统计信息

  • 总下载量: 1.57k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2017-03-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固