PHP code example of chiho / wechatshop

1. Go to this page and download the library: Download chiho/wechatshop 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/ */

    

chiho / wechatshop example snippets


{
    "  "chiho/wechatshop": "1.0.0"
    }
}

$product = new CHWechatShopProduct();
$product->setName('name')->setCategoryId('cat_id')->setMainImage('imageUrl')->addImage('imageUrl')->addDetailText('text'));
CHWechatShop::productCreate($product);

CHWechatShop::productRemove('product_id');

$product = new CHWechatShopProduct();
$product->setName('name')->setCategoryId('cat_id')->setMainImage('imageUrl')->addImage('imageUrl')->addDetailText('text'));
CHWechatShop::productModify($product);

CHWechatShop::getProductByStatus(CHWechatShopConst::PRODUCT_SHELVE);

CHWechatShop::getProduct('product_id');

CHWechatShop::productStatus('product_id', CHWechatShopConst::PRODUCT_SHELVE);

CHWechatShop::getCategories('cat_id');

CHWechatShop::getCategorySKU('cat_id');

CHWechatShop::getCategoryProperty('cat_id');

CHWechatShop::addStock('product_id', 1);

CHWechatShop::reduceStock('product_id', 1);

$templete = new CHWechatShopExpressTemplate();
$normalFee = new CHWechatShopExpressFee();
$customFee = new CHWechatShopExpressFee();
$normalFee->setFee(1, 100, 1, 200);
$customFee->setFee(2, 200, 2, 400)->setCity('中国', '广东省', '广州市');
$templete->setName('name')->setAssumer(CHWechatShopConst::BUYER_PAY_DELIVERY_FEE)->addFee(CHWechatShopConst::DELIVERY_TYPE_ID_EXPRESS, $normalFee, array($customFee));
CHWechatShop::expressTemplateCreate($templete);

$templete = new CHWechatShopExpressTemplate();
$normalFee = new CHWechatShopExpressFee();
$customFee = new CHWechatShopExpressFee();
$normalFee->setFee(1, 100, 1, 200);
$customFee->setFee(2, 200, 2, 400)->setCity('中国', '广东省', '广州市');
$templete->setName('name')->setAssumer(CHWechatShopConst::BUYER_PAY_DELIVERY_FEE)->addFee(CHWechatShopConst::DELIVERY_TYPE_ID_EXPRESS, $normalFee, array($customFee));
CHWechatShop::expressTemplateModify('templete_id', $templete);

CHWechatShop::getExpressTemplate('templete_id');

CHWechatShop::getAllExpressTemplate();

CHWechatShop::expressTemplateRemove('templete_id');

$group = new CHWechatShopGroup();
$group->setGroupName('name')->addProduct('product_id');
CHWechatShop::groupCreate($group);

CHWechatShop::groupRemove('group_id');

CHWechatShop::updateGroupName('group_id', 'name');

$modify = new CHWechatShopGroupModify('product_id', CHWechatShopConst::GROUP_PRODUCT_ADD);
CHWechatShop::updateGroupProduct('group_id', array($modify));

CHWechatShop::getAllGroup();

CHWechatShop::getGroup('group_id');

$shelf = (new CHWechatShopShelf())->setShelfBanner('imageUrl')->setShelfName('name');
$shelf->addShelfData((new CHWechatShopShelfData1())->setProductCount(1)->setGroupId('group_id'));
CHWechatShop::shelfCreate($shelf);

CHWechatShop::shelfRemove('shelf_id');

$shelf = (new CHWechatShopShelf())->setShelfBanner('imageUrl')->setShelfName('name');
$shelf->addShelfData((new CHWechatShopShelfData1())->setProductCount(1)->setGroupId('group_id'));
CHWechatShop::shelfModify($shelf);

CHWechatShop::getAllShelf();

CHWechatShop::getShelf('shelf_id');

CHWechatShop::getOrder('order_id');

CHWechatShop::getOrderByStatus(CHWechatShopConst::ORDER_STATUS_TO_SEND, 0, 1491795684);

$delivery = new CHWechatShopDelivery();
$delivery->setOrderId('order_id')->setDeliveryTrackNo('track_no')->setDeliveryCompany(CHWechatShopConst::EXPRESS_ID_SHUNFENG);
CHWechatShop::setDelivery($delivery);

CHWechatShop::orderClose('order_id');

CHWechatShop::uploadImage('filePath', "imageName");