diff --git a/app/Console/Commands/ProductUpdateQta.php b/app/Console/Commands/ProductUpdateQta.php index de4bb041..fd1563db 100755 --- a/app/Console/Commands/ProductUpdateQta.php +++ b/app/Console/Commands/ProductUpdateQta.php @@ -18,6 +18,8 @@ use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\DB; +use App\Helpers\MyConfig; + class ProductUpdateQta extends Command { /** @@ -95,7 +97,7 @@ class ProductUpdateQta extends Command $titolo = $productsku['title']; // Se il libro è ancora in Prevendita e la quantità è > QTA_MINIMA_PER_PREVENDITA, allora non aggiornare la QTA // deve rimanere a > QTA_MINIMA_PER_PREVENDITA per poter vedere "In Preordine" - if ($inprevendita && $qtyinstock > QTA_MINIMA_PER_PREVENDITA) { + if ($inprevendita && $qtyinstock > MyConfig::$qtaInPrevendita) { $aggiorna = false; } diff --git a/app/CustomFuncPao.php b/app/CustomFuncPao.php index 4508f7a4..f3d49721 100644 --- a/app/CustomFuncPao.php +++ b/app/CustomFuncPao.php @@ -1,6 +1,7 @@ self::findInsideProduct($product, self::CAMPO_PREORDINE) === 'yes', + 'active' => self::findInsideProduct($product, MyConfig::$campoPreordine) === 'yes', 'date' => self::findInsideProduct($product, '_ywpo_for_sale_date') ]; } @@ -1107,7 +1106,7 @@ class ArticleFormatter { $baseUrl = $article->permalink . '/apimacro/public/aggiornapreorder/' . $article->IdArticolo; - if (!$preorderInfo['active'] || $stockInfo['quantity'] < self::QTA_MINIMA_PER_PREVENDITA) { + if (!$preorderInfo['active'] || $stockInfo['quantity'] < MyConfig::$qtaMinima) { return sprintf( 'Imposta in PRE-ORDINE!%s', $baseUrl, @@ -1148,7 +1147,8 @@ class ArticleFormatter } } -function getRigaArticoloByArt($article, $index, $separator) { +function getRigaArticoloByArt($article, $index, $separator) +{ return ArticleFormatter::getArticleRow($article, $index, $separator); } diff --git a/app/Helpers/includes.php b/app/Helpers/includes.php new file mode 100644 index 00000000..2588f61e --- /dev/null +++ b/app/Helpers/includes.php @@ -0,0 +1,14 @@ +class MyConfig +{ + static public $qtaInPrevendita; + static public $qtaMinima; + static public $campoPreordine; + + public function __construct() + { + self::$qtaInPrevendita = config('preordini.QTA_IN_PREVENDITA'); + self::$qtaMinima = config('preordini.QTA_MINIMA_PER_PREVENDITA'); + self::$campoPreordine = config('preordini.CAMPO_PREORDINE'); + } +} + diff --git a/composer.json b/composer.json index 28a8504e..9eb972f2 100644 --- a/composer.json +++ b/composer.json @@ -41,6 +41,9 @@ "classmap": [ "database/seeds", "database/factories" + ], + "files": [ + "app/Helpers/includes.php" ] }, "autoload-dev": { diff --git a/config/preordini.php b/config/preordini.php new file mode 100644 index 00000000..a0efebed --- /dev/null +++ b/config/preordini.php @@ -0,0 +1,7 @@ + 10000, + 'QTA_MINIMA_PER_PREVENDITA' => 9000, + 'CAMPO_PREORDINE' => '_ywpo_preorder', +];