Skip to content

Commit

Permalink
Merge branch 'master' into v4
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Poyigi <[email protected]>
  • Loading branch information
sampoyigi committed Feb 4, 2024
1 parent 8676b73 commit 7c637da
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 11 deletions.
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ parameters:

-
message: "#^Call to an undefined static method Igniter\\\\Cart\\\\Models\\\\CartSettings\\:\\:get\\(\\)\\.$#"
count: 3
count: 4
path: src/Extension.php

-
Expand Down
7 changes: 4 additions & 3 deletions resources/js/cartitem.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@
var $button = $(event.currentTarget),
$container = $button.closest('[data-toggle="quantity"]'),
$input = $container.find('input'),
oldValue = parseFloat($input.val())
oldValue = parseFloat($input.val()),
minQuantity = parseFloat(this.options.minQuantity)

if ($button.data('operator') === 'plus') {
$input.val(oldValue+this.options.minQuantity)
$input.val(oldValue+minQuantity)
} else {
$input.val((oldValue > 0) ? oldValue-this.options.minQuantity : 0)
$input.val((oldValue > 0) ? oldValue-minQuantity : 0)
}

$input.trigger('input');
Expand Down
5 changes: 4 additions & 1 deletion resources/lang/en/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
'alert_no_search_query' => 'Please type in a postcode/address to check if we can deliver to you.',
'alert_location_closed' => 'Sorry, you can\'t place an order now, we are currently closed,<br /> please come back later during our opening times.',
'alert_min_delivery_order_total' => 'Order total is below the %s minimum order total. <br />You need to spend more to order.',
'alert_min_order_total' => 'Order total is below the %s minimum order total. <br />You need to spend more to order.',
'alert_coupon_removed' => 'Your coupon has been removed successfully.',
'alert_coupon_applied' => 'Your coupon has been applied successfully.',
'alert_coupon_invalid' => 'Please enter a valid coupon.',
Expand Down Expand Up @@ -240,6 +241,7 @@
'text_leave_review' => 'Leave review',
'text_no_payment' => 'No Payment',
'text_login_to_view_more' => 'For more information about your order, please create an account or login.',
'text_title_cancel' => 'Cancel Order',

'column_id' => 'Order no.',
'column_status' => 'Status',
Expand All @@ -257,7 +259,7 @@

'button_order' => 'Place New Order',
'button_reorder' => 'Reorder',
'button_cancel' => 'Cancel',
'button_cancel' => 'Cancel order',
'button_view_order' => 'View/Reorder',
'button_back' => 'Back',

Expand Down Expand Up @@ -328,6 +330,7 @@
'label_restaurant_address' => 'Address',
'label_payment_method' => 'Payment Method',
'label_total_items' => 'Total Items',
'label_cancel_reason' => 'Reason for cancellation',

'notify_status_updated_title' => 'Order status updated',
'notify_assigned_title' => 'Order assigned',
Expand Down
10 changes: 10 additions & 0 deletions resources/models/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@
'label' => 'lang:igniter.cart::default.orders.column_total',
'type' => 'currency',
],
'telephone' => [
'label' => 'lang:igniter.cart::default.orders.label_telephone',
'invisible' => true,
'searchable' => true,
],
'email' => [
'label' => 'lang:igniter::admin.label_email',
'invisible' => true,
'searchable' => true,
],
'updated_at' => [
'label' => 'lang:igniter::admin.column_date_updated',
'type' => 'datesince',
Expand Down
27 changes: 27 additions & 0 deletions src/AutomationRules/Conditions/OrderAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public function defineModelAttributes()
'location_id' => [
'label' => 'Location ID',
],
'status_id' => [
'label' => 'Last order status ID',
],
'total_items' => [
'label' => 'Cart total items',
],
Expand All @@ -49,6 +52,12 @@ public function defineModelAttributes()
'hours_until' => [
'label' => 'Hours until order delivery/collection time',
],
'days_since' => [
'label' => 'Days since order delivery/collection time',
],
'days_until' => [
'label' => 'Days until order delivery/collection time',
],
'history_status_id' => [
'label' => 'Recent order status IDs (eg. 1,2,3)',
],
Expand All @@ -73,6 +82,24 @@ public function getHoursUntilAttribute($value, $order)
: 0;
}

public function getDaysSinceAttribute($value, $order)
{
$currentDateTime = now();

return $currentDateTime->isAfter($order->order_datetime)
? $order->order_datetime->diffInDays($currentDateTime)
: 0;
}

public function getDaysUntilAttribute($value, $order)
{
$currentDateTime = now();

return $currentDateTime->isBefore($order->order_datetime)
? $currentDateTime->diffInDays($order->order_datetime)
: 0;
}

public function getHistoryStatusIdAttribute($value, $order)
{
return $order->status_history()->pluck('status_id')->implode(',');
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ public function getOrderDates()
return $this->pluckDates('created_at');
}

public function markAsCanceled()
public function markAsCanceled(array $statusData = [])
{
$canceled = false;
if ($this->addStatusHistory(setting('canceled_order_status'))) {
if ($this->addStatusHistory(setting('canceled_order_status'), $statusData)) {
$canceled = true;
OrderCanceledEvent::dispatch($this);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Requests/MenuRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function rules()
'order_restriction.*' => ['nullable', 'string'],
'menu_status' => ['boolean'],
'mealtime_id' => ['nullable', 'integer'],
'menu_priority' => ['nullable', 'integer'],
'menu_priority' => ['min:0', 'integer'],
];
}
}
7 changes: 4 additions & 3 deletions tests/Requests/MenuTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ function () {
expect('numeric')->toBeIn(array_get($rules, 'menu_price'));
});

it('has min:0 rule for menu_price input', function () {
it('has min:0 rule for menu_price, menu_priority input', function () {
$rules = (new MenuRequest)->rules();

expect('min:0')->toBeIn(array_get($rules, 'menu_price'));
expect('min:0')->toBeIn(array_get($rules, 'menu_price'))
->and('min:0')->toBeIn(array_get($rules, 'menu_priority'));
});

it('has min:1 rule for minimum_qty input', function () {
Expand Down Expand Up @@ -108,7 +109,7 @@ function () {
order_restriction.*, mealtime_id, menu_priority',
function () {
$rules = (new MenuRequest)->rules();
$inputNames = ['order_restriction.*', 'mealtime_id', 'menu_priority'];
$inputNames = ['order_restriction.*', 'mealtime_id'];
$testExpectation = null;

foreach ($inputNames as $key => $inputName) {
Expand Down

0 comments on commit 7c637da

Please sign in to comment.