ソースを参照

[Boutique] Gestion des accessoires

feature/rotating_product
Guillaume Bourgeois 4ヶ月前
コミット
d09e096942
3個のファイルの変更14行の追加8行の削除
  1. +8
    -3
      domain/Order/Order/OrderResolver.php
  2. +2
    -2
      producer/views/order/order.php
  3. +4
    -3
      producer/web/js/vuejs/order-order.js

+ 8
- 3
domain/Order/Order/OrderResolver.php ファイルの表示

@@ -10,7 +10,6 @@ use domain\Feature\Feature\FeatureChecker;
use domain\Product\Accessory\Accessory;
use domain\Product\Product\Product;
use domain\Product\Product\ProductSolver;
use yii\base\ErrorException;

class OrderResolver extends AbstractResolver
{
@@ -93,8 +92,14 @@ class OrderResolver extends AbstractResolver

public function getProductQuantityMaxOrderable(Product $product, Distribution $distribution, Order $orderCurrent = null): ?float
{
return $this->orderSolver->getProductQuantity($product, $orderCurrent ? [$orderCurrent] : [])
+ $this->getProductQuantityRemaining($product, $distribution, $orderCurrent);
$productQuantity = $this->orderSolver->getProductQuantity($product, $orderCurrent ? [$orderCurrent] : []);
$productQuantityRemaining = $this->getProductQuantityRemaining($product, $distribution, $orderCurrent);

if(is_null($productQuantityRemaining)) {
return null;
}

return $productQuantity + $productQuantityRemaining;
}

public function getQuantityOfAccessoryAvailableInDistribution(

+ 2
- 2
producer/views/order/order.php ファイルの表示

@@ -354,7 +354,7 @@ $this->setMeta('description', $producerModule->getSeoGenerator()->generateMetaDe
<span v-if="product.weight">({{ product.weight }}&nbsp;g)</span>
</span>
<div>
<span v-if="product.quantity_max > 0 && (product.quantity_remaining <= 0 || product.quantity_remaining * product.coefficient_unit < product.step)"
<span v-if="product.quantity_max != null && (product.quantity_remaining <= 0 || product.quantity_remaining * product.coefficient_unit < product.step)"
class="badge bg-danger">Épuisé</span>
</div>
<div class="description" v-if="product.description.length">
@@ -412,7 +412,7 @@ $this->setMeta('description', $producerModule->getSeoGenerator()->generateMetaDe
<button class="btn btn-secondary btn-plus"
type="button"
@click="productQuantityClick(product, product.unit == 'piece' ? 1 : parseFloat(product.step))"
:disabled="loadingProducts || product.quantity_remaining <= 0 || product.quantity_form >= product.quantity_max * product.coefficient_unit">
:disabled="loadingProducts || (product.quantity_remaining != null && product.quantity_remaining <= 0) || (product.quantity_max != null && product.quantity_form >= product.quantity_max * product.coefficient_unit)">
<i class="bi bi-plus-lg"></i></button>
</span>
</div>

+ 4
- 3
producer/web/js/vuejs/order-order.js ファイルの表示

@@ -524,9 +524,10 @@ var app = new Vue({
},
productQuantityClick: function(product, quantity) {
if(this.products[product.index].quantity_form + quantity >= 0
&& this.products[product.index].quantity_form + quantity <= this.products[product.index].quantity_max * this.products[product.index].coefficient_unit
&& (quantity <= (this.products[product.index].quantity_remaining * this.products[product.index].coefficient_unit)
|| this.products[product.index].quantity_remaining == null)
&& (this.products[product.index].quantity_max == null
|| this.products[product.index].quantity_form + quantity <= this.products[product.index].quantity_max * this.products[product.index].coefficient_unit)
&& (this.products[product.index].quantity_remaining == null
|| (quantity <= (this.products[product.index].quantity_remaining * this.products[product.index].coefficient_unit)))
) {
var theQuantity = parseFloat(this.products[product.index].quantity_form) + parseFloat(quantity);
this.products[product.index].quantity_form = parseFloat(theQuantity.toFixed(2)) ;

読み込み中…
キャンセル
保存