last modifications

This commit is contained in:
Alexis Gousseau 2022-10-27 17:20:38 +02:00
parent 11e8749bbb
commit b58a8df2ec
3 changed files with 24 additions and 37 deletions

View file

@ -357,25 +357,34 @@ class OrderTunnelController extends Controller
$order = Order::where('reference', '=', $reference)->firstOrFail();
// Check total price of this customer commands for a specific delivery day.
$date = CarbonImmutable::create(explode('/', $tsday)[2], explode('/', $tsday)[1], explode('/', $tsday)[0]);
$start = $date->startOfWeek(Carbon::MONDAY)->format('Y-m-d');
$end = $date->endOfWeek(Carbon::SUNDAY)->format('Y-m-d');
$date = CarbonImmutable::create(
explode('/', $tsday)[2],
explode('/', $tsday)[1],
explode('/', $tsday)[0]
);
$start = $date->startOfWeek(Carbon::MONDAY);
$end = $date->endOfWeek(Carbon::SUNDAY);
$customerOrders = Order::where('customer_id', '=', $order->customer_id)
->where('status_id', '=', 3)
->get();
$totalPrice = 0;
foreach ($customerOrders as $key => $customerOrder) {
$timeslot_day = Carbon::createFromFormat('d/m/Y', $customerOrder->timeslot->day);
if (
strcasecmp($customerOrder->timeslot->day, $start) > 0 &&
strcasecmp($customerOrder->timeslot->day, $end) > 0
$timeslot_day >= $start &&
$timeslot_day <= $end
) {
$totalPrice += $customerOrder->total;
}
}
if ($totalPrice > 200) {
return redirect()->route('account.order-detail', ['reference' => $order->reference])
->with('message', 'Le montant total pour cette date de livraison est dépassé (200€).
->with('message', 'Le montant total pour cette date de livraison est dépassé (200€ maximum).
Veuillez modifier cette dernière pour la valider.');
}
if ($order->total > 200) {
return redirect()->route('account.order-detail', ['reference' => $order->reference])
->with('message', 'Le montant total de cette commande est dépassé (200€ maximum).
Veuillez modifier cette dernière pour la valider.');
}

View file

@ -45,7 +45,7 @@
</section>
<div class="title-small d-flex flex-row justify-content-between align-items-center font-Barlow-bold px-2 px-md-4">
<p v-show="!emptybasket">Total</p>
<p v-show="!emptybasket">{{currencyFormatter(cartTotals.totalTTC)}}</p>
<p v-show="!emptybasket">{{ currencyFormatter(cartTotals.totalTTC) }}</p>
</div>
<div class="d-flex flex-row-reverse justify-content-between align-items-center px-2 px-md-4">
<a class="btn btn-product text-uppercase font-Barlow-bold rounded-4" v-show="!emptybasket" href="/commande/recap">Commander</a>
@ -71,7 +71,6 @@
</section>
</template>
<script>
export default {
computed: {
@ -107,14 +106,13 @@
let breaker = false;
this.panier.forEach(element => {
if(element.cartItem.id == product_id) {
element.cartItem.qty += qtty;
}
if(element.cartItem.qty == 0) {
element.cartItem.qty += qtty;
}
if(element.cartItem.qty <= 0) {
this.removeItem(element.cartItem.rowId);
breaker = true;
}
});
if(!breaker) {
axios.post('/ajax/add-to-cart', {
id: product_id,
@ -122,8 +120,7 @@
instance: 'panier',
}).then(
(response) => {
let result = response.data;
this.updateStore(result);
this.updateStore(response.data);
}
)
.catch(function (error) {
@ -133,31 +130,13 @@
});
}
},
async multiaddtocart(arItems) {
const data = await axios.post('/ajax/multi-add-to-cart', {
items: arItems,
instance: 'panier',
}).then(
(response) => {
let result = response.data;
this.updateStore(result);
}
)
.catch(function (error) {
console.log(error);
this.response = "Erreur lors de la modification du panier.";
this.processing = false;
});
return data;
},
removeItem(rowId) {
axios.post('/ajax/remove-from-cart', {
rowId: rowId,
instance: 'panier',
}).then(
(response) => {
let result = response.data;
this.updateStore(result);
this.updateStore(response.data);
}
)
.catch(function (error) {
@ -173,8 +152,7 @@
instance: 'panier',
}).then(
(response) => {
let result = response.data;
this.updateStore(result);
this.updateStore(response.data);
}
)
.catch(function (error) {

View file

@ -55,7 +55,7 @@
@endcan
</div>
@if ($product->weight_variable)
<p class="fst-italic text-muted">*Produit vendu au kilo</p>
<p class="fst-italic text-muted">*Produit vendu au kilo : @fmt_currency($product->priceKgTtc)/kg</p>
@endif
</div>
<!-- PRODUCT'S DETAILS -->