Skip to content

Repository files navigation

Good Code Parser

code-stylerun-testsPackagist VersionPackagist DownloadsPackagist Dependency VersionPackagist StarsPackagist License

A robust code specification is crucial within the commercial market industry, especially for online stores like Amazon. The integration of online stores with Warehouse Management Systems (WMS) is essential as both systems handle extensive seller and product data. Therefore, we recommend implementing a solid structure and providing robust support for these systems.

These specifications cover a variety of online stores, including Coupang, 11th Street, Naver Storefarm, and many others for a while.

We have provided the API Documentation on the web. For more information, please visit https://www.palgle.com/good-code/ ❤️

Features

  • Normal good code parser
  • Gift good code parser
  • Set good code parser
  • Complex good code parser
  • Option Good code parser(No code, it matched by name)
  • Receipt code parser
  • Location code parser
  • SKU parser

Install

composer require cable8mm/good-code

Usage

Production codes for Laravel

Visit repository - https://github.com/cable8mm/aipro

<?phpuseApp\Models\OptionGood;
useCable8mm\GoodCode\Enums\GoodCodeType;
useCable8mm\GoodCode\GoodCode;
/** * For option products, retrieve the master_code of the option and update it. */if (GoodCodeType::of($this->data->get('sellerGoodsCd')) == GoodCodeType::OPTION) {
$code = GoodCode::of(
$this->data->get('sellerGoodsCd'),
option: $this->data->get('option'),
callback: function ($key, $option) {
return OptionGood::findMasterCode($key)->option($option)->first()->masterCode();
}
)->code();
$this->data->put('masterGoodsCd', $code);
}
<?phpuseCable8mm\GoodCode\Enums\GoodCodeType;
useCable8mm\GoodCode\GoodCode;
useCable8mm\GoodCode\ValueObjects\SetGood;
/** * For composite and gift products, retrieve the set product and update the master_code. */if (
GoodCodeType::of($this->data->get('sellerGoodsCd')) == GoodCodeType::COMPLEX
|| GoodCodeType::of($this->data->get('sellerGoodsCd')) == GoodCodeType::GIFT
) {
$code = GoodCode::of(
$this->data->get('sellerGoodsCd'),
callback: function ($key) {
return SetGood::findComCode($key)->master_code;
}
)->code();
$this->data->put('masterGoodsCd', $code);
}

Example codes

set-code

<?phpuseCable8mm\GoodCode\GoodCode;
print GoodCode::of('SET7369x4zz4235x6')->value();
//=> ['7369'=>4,'4235'=>6]print GoodCode::setCodeOf(['1234' => 2, '5678' => 1,])->code();
//=> 'set1234x2ZZ5678x1'

complex-code

<?phpuseCable8mm\GoodCode\GoodCode;
print GoodCode::of('COM10', callback: function ($key) {
$a = [ 10 => '123'];
return$a[$key];
})->value();
//=> '123'

gift-code

<?phpuseCable8mm\GoodCode\GoodCode;
print GoodCode::of('GIF11', callback: function ($key) {
$a = [
11 => '456',
];
return$a[$key];
});
//=> '456'

option-code

Tip

option-code are matching with bothoption-codeandoption-good-option name. Unfortunately all of online shops like Coupang and 11st have not send any key for option to sellers.

<?phpuseCable8mm\GoodCode\GoodCode;
print GoodCode::of($optionCode, option: $optionName, callback: function ($key, $option) {
$a = [
10 => [
'Super Smash Bros. Ultimate' => 'COM4',
'Animal Crossing: New Horizons' => '3124',
'The Legend of Zelda: Tears of the Kingdom' => '1234',
'Call of Duty®: Black Ops 6' => '2314',
'Grand Theft Auto V' => '43123',
'42342' => 'Marvel\'s Spider-Man 2',
],
];
return$a[$key][$option];
})->value();
//=> '3124'

Special value object - SetGood

<?phpuseCable8mm\GoodCode\ValueObjects\SetGood;
print SetGood::of('SET43x3zz253x3')->goods();
//=> ['43' => 3, '253' => 3]print SetGood::ofArray(['43' => 3, '253' => 3])->code();
//=> SET43x3zz253x3

Receipt Code

<?phpuseCable8mm\GoodCode\ReceiptCode;
print ReceiptCode::of('PO-20250312-0001')->code;
//=> PO-20250312-0001print ReceiptCode::of('PO-20250312-0001')->prefix;
//=> POprint ReceiptCode::of('PO-20250312-0001')->ymd;
//=> 20250312print ReceiptCode::of('PO-20250312-0001')->number;
//=> 0001print ReceiptCode::of('PO-20250312-0001')->nextCode();
//=> PO-20250312-0002print ReceiptCode::of()->nextCode();
//=> PO-[Today's ymd]-0001print ReceiptCode::of(prefix: 'CT')->nextCode();
//=> CT-[Today's ymd]-0001

Location Code

print LocationCode::of(warehouse: 'AUK', rack: 'R3', shelf: 'S32')->locationCode();
print LocationCode::of(['warehouse' => 'AUK', 'rack' => 'R3', 'shelf' => 'S32'])->locationCode();
print (string) LocationCode::of(warehouse: 'AUK', rack: 'R3', shelf: 'S32'); // Stringable supported//=> AUK-R3-S32

SKU

print Sku::of(code: 123, prefix: 'PO'); //=> PO123print Sku::of(123); //=> 123print Sku::of(123, prefix: 'PO'); //=> PO123

Formatting

composer lint

Test

composer test

Support codes

TypeNotationDescriptionImplement
Normal Code-Match only one goodYes
Set CodeSETMatch one more good, max 255 charactersYes
Complex CodeCOMShorten code for Set CodeYes
Gift CodeGIFAlias Complex CodeYes
Option CodeOPTVery complicated code. Not mastercode, but code + search name.(eq. wemakeprice, naver petWindow and all most OpenMarket options)Yes

License

The Good Code Parser is open-sourced software licensed under the MIT license.

About

Create a general code specification for building a WMS (Warehouse Management System), and specify parsers and implementation guidelines.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages