1. Go to this page and download the library: Download cable8mm/good-code library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cable8mm / good-code example snippets
useApp\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);
}
useCable8mm\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);
}