Bladeren bron

[Espace producteur] Abonnements : visibilité produits #1081

feature/souke
Guillaume 1 jaar geleden
bovenliggende
commit
6a95c08864
4 gewijzigde bestanden met toevoegingen van 32 en 23 verwijderingen
  1. +24
    -11
      common/logic/Product/Product/Service/ProductSolver.php
  2. +1
    -11
      producer/controllers/OrderController.php
  3. +6
    -0
      producer/controllers/SubscriptionController.php
  4. +1
    -1
      producer/web/js/vuejs/subscription-form.js

+ 24
- 11
common/logic/Product/Product/Service/ProductSolver.php Bestand weergeven

@@ -180,14 +180,13 @@ class ProductSolver extends AbstractService implements SolverInterface
$producer = GlobalParam::getCurrentProducer();
if ($producer->option_export_display_product_reference
&& $product->reference
&& strlen($product->reference) > 0)
{
&& strlen($product->reference) > 0) {
return $product->reference;
}

return $product->name;
}
public function isProductActiveByDay(Product $product, string $day): bool
{
return $product->active && $product->$day;
@@ -195,7 +194,7 @@ class ProductSolver extends AbstractService implements SolverInterface

public function getProductFieldNameQuantityMax(string $day): string
{
return 'quantity_max_'.$day;
return 'quantity_max_' . $day;
}

public function isProductQuantityMaxDefinedByDay(Product $product, string $day): bool
@@ -207,22 +206,21 @@ class ProductSolver extends AbstractService implements SolverInterface
public function getProductQuantityMaxByDay(Product $product, string $day): ?float
{
$quantityMax = ($product->quantity_max && $product->quantity_max > 0) ? $product->quantity_max : null;
if($this->isProductQuantityMaxDefinedByDay($product, $day)) {
if ($this->isProductQuantityMaxDefinedByDay($product, $day)) {
$fieldQuantityMax = $this->getProductFieldNameQuantityMax($day);
$quantityMax = $product->$fieldQuantityMax;
}
return $quantityMax;
}

public function isPublic(Product $product): bool
{
if($product->available_on_points_sale) {
if ($product->available_on_points_sale) {
return true;
}
else {
foreach($product->productPointSale as $productPointSale) {
if($productPointSale->pointSale && $this->pointSaleSolver->isPublic($productPointSale->pointSale)) {
} else {
foreach ($product->productPointSale as $productPointSale) {
if ($productPointSale->pointSale && $this->pointSaleSolver->isPublic($productPointSale->pointSale)) {
return true;
}
}
@@ -230,4 +228,19 @@ class ProductSolver extends AbstractService implements SolverInterface

return false;
}

public function filterProductsByPointSale(array $productArray, PointSale $pointSale = null): array
{
$productArrayFilter = [];

if($pointSale) {
foreach ($productArray as $product) {
if ($this->isAvailableOnPointSale($product, $pointSale)) {
$productArrayFilter[] = $product;
}
}
}

return $productArrayFilter;
}
}

+ 1
- 11
producer/controllers/OrderController.php Bestand weergeven

@@ -931,17 +931,7 @@ class OrderController extends ProducerBaseController
->orderBy('product_distribution.active DESC, order ASC')
->all();

$productsArrayFilter = [];

// filtre sur les points de vente
if($pointSale) {
foreach ($productsArray as $product) {
if ($productManager->isAvailableOnPointSale($product, $pointSale)) {
$productsArrayFilter[] = $product;
}
}
}

$productsArrayFilter = $productManager->filterProductsByPointSale($productsArray, $pointSale);

$indexProduct = 0;
foreach ($productsArrayFilter as $key => &$product) {

+ 6
- 0
producer/controllers/SubscriptionController.php Bestand weergeven

@@ -274,6 +274,11 @@ class SubscriptionController extends ProducerBaseController
}
}

$productPointSaleArray = [];
foreach($product->productPointSale as $productPointSale) {
$productPointSaleArray[] = $productPointSale->id_point_sale;
}

$product = array_merge(
$product->getAttributes(),
[
@@ -287,6 +292,7 @@ class SubscriptionController extends ProducerBaseController
'user_producer' => $userProducer,
'point_sale' => $pointSale
]),
'product_point_sale_array' => $productPointSaleArray
]
);


+ 1
- 1
producer/web/js/vuejs/subscription-form.js Bestand weergeven

@@ -136,7 +136,7 @@ var app = new Vue({
(!this.thursday || (this.thursday && product.thursday)) &&
(!this.friday || (this.friday && product.friday)) &&
(!this.saturday || (this.saturday && product.saturday)) &&
(!this.sunday || (this.sunday && product.sunday));
(!this.sunday || (this.sunday && product.sunday)) ;

if (!available) {
product.quantity_form = 0;

Laden…
Annuleren
Opslaan