소스 검색

[Espace producteur] Abonnements : visibilité produits #1081

feature/souke
Guillaume 1 년 전
부모
커밋
6a95c08864
4개의 변경된 파일32개의 추가작업 그리고 23개의 파일을 삭제
  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 파일 보기

@@ -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 파일 보기

@@ -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 파일 보기

@@ -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 파일 보기

@@ -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;

Loading…
취소
저장