preordini
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\ArticoliFatturati;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
use Codexshaper\WooCommerce\Facades\Product;
|
||||
use Illuminate\Console\Command;
|
||||
@@ -19,6 +20,7 @@ use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
|
||||
use App\Orderdetail;
|
||||
use App\Services\ProductLogger;
|
||||
use App\Order as AppOrder;
|
||||
@@ -28,11 +30,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
use Illuminate\Support\Facades\Request;
|
||||
|
||||
|
||||
define('QTA_IN_PREVENDITA', 10000);
|
||||
define('QTA_MINIMA_PER_PREVENDITA', 9000);
|
||||
|
||||
define('CAMPO_PREORDINE', '_ywpo_preorder');
|
||||
use App\Helpers\MyConfig;
|
||||
|
||||
setlocale(LC_TIME, 'it_IT.UTF-8');
|
||||
|
||||
@@ -141,7 +139,7 @@ function setPreOrder($sku, $aggiornapreordine, $debug)
|
||||
}
|
||||
|
||||
//$campoPreOrder = '_wpro_variable_is_preorder';
|
||||
$campoPreOrder = CAMPO_PREORDINE;
|
||||
$campoPreOrder = MyConfig::$campoPreordine;
|
||||
|
||||
if ($product) {
|
||||
$titolo = $product['name'];
|
||||
@@ -211,7 +209,7 @@ function setPreOrder($sku, $aggiornapreordine, $debug)
|
||||
}
|
||||
}
|
||||
|
||||
$data['stock_quantity'] = QTA_IN_PREVENDITA;
|
||||
$data['stock_quantity'] = MyConfig::$qtaInPrevendita;
|
||||
|
||||
if ($debug) {
|
||||
echo "Data:";
|
||||
@@ -972,6 +970,7 @@ function findInsideProduct(array $prodotto, string $miocampo): ?string
|
||||
|
||||
class ArticleFormatter
|
||||
{
|
||||
|
||||
public static function getArticleRow($article, $index, $separator)
|
||||
{
|
||||
try {
|
||||
@@ -1026,7 +1025,7 @@ class ArticleFormatter
|
||||
}
|
||||
|
||||
return [
|
||||
'active' => 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(
|
||||
'<a href="%s/1/" target="_blank">Imposta in PRE-ORDINE!</a>%s',
|
||||
$baseUrl,
|
||||
@@ -1148,7 +1147,8 @@ class ArticleFormatter
|
||||
}
|
||||
}
|
||||
|
||||
function getRigaArticoloByArt($article, $index, $separator) {
|
||||
function getRigaArticoloByArt($article, $index, $separator)
|
||||
{
|
||||
return ArticleFormatter::getArticleRow($article, $index, $separator);
|
||||
}
|
||||
|
||||
|
||||
14
app/Helpers/includes.php
Normal file
14
app/Helpers/includes.php
Normal file
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@
|
||||
"classmap": [
|
||||
"database/seeds",
|
||||
"database/factories"
|
||||
],
|
||||
"files": [
|
||||
"app/Helpers/includes.php"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
|
||||
7
config/preordini.php
Normal file
7
config/preordini.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'QTA_IN_PREVENDITA' => 10000,
|
||||
'QTA_MINIMA_PER_PREVENDITA' => 9000,
|
||||
'CAMPO_PREORDINE' => '_ywpo_preorder',
|
||||
];
|
||||
Reference in New Issue
Block a user