Timeslot Widget does not update after a new date is set

Created on 9 October 2023, about 1 year ago
Updated 10 October 2023, about 1 year ago

Problem/Motivation

On the order information page the Timeslot Widget appears just like the module screenshot below.

I have set the length of days range to display to 7 (default)
Starting from today.

My widget displays todays date and timeframes that I can select.

But I don't want to select today as my delivery date I want tomorrow.
So I edit the date in the widget to tomorrow but it does not update the time frames set for tomorrow.
The timeframes just stay set to today no matter what date I change it to.

Would it be posable to make the widget update in real time.

If the day range is set to 7 days then only 7 dates should be availably in a date select dropdown.

When you select a date in the drop down the timeframe select widget should update in real time to show the availably timeframes of that date.

My widget does not show how many capacity slots are left, It is not visible at all.
But if it was it should also update after a timeframe is set on a selected date.

Steps to reproduce

1. setup day capacity - Morning Slot, Afternoon Slot
2. setup days Monday to Friday with both Morning and Afternoon capacity
3. create a timeslot "Week Days"
4. Set timeslot on order checkout
5. Set day range to 7

6. add product to cart
7. checkout
8. on order information page see todays date (Monday) and availably timeframes.
9. select morning timeframe slot
10. review order (Timeslot set for today and to morning timeframe)
11. Edit timeslot in order review mode.
12. Change date to tomorrow (timeframes does not update to what is availably for tomorrow)
13. Change date to weekend date (no timeslots set on weekends) then see timeframes still show as availably
14. Save weekend date and in review timeslot will show weekend date with timeslot morning (this is not availably and should not be posable to show in review)
15. Click "Edit" timeslot in review pane and then the weekend date will show in the timeslot date and the following message
"There are no available time frames for this date. Please, choose a different date." This is the correct outcome as there are no weekend delivery timeslots.

I also got this error message trying to review my order after setting a date and then selecting a timeslot that does not exist for that date

Location: /checkout/2/review
Referrer: /checkout/2/order_information
Message:	TypeError: Drupal\commerce_timeslots\Services\CommerceTimeSlots::getTimeSlotToArray(): Argument #1 ($time_frame) must be of type int, string given, called in \modules\contrib\commerce_timeslots\src\Plugin\Commerce\CheckoutPane\TimeSlotPane.php on line 169 in Drupal\commerce_timeslots\Services\CommerceTimeSlots->getTimeSlotToArray() (line 555 of \modules\contrib\commerce_timeslots\src\Services\CommerceTimeSlots.php).

Proposed resolution

Make the Timeslot widget update in real time.
Make the day range date a select list of (set value days)
Update timeframes when a new date is selected
Update capacity after new timeframe is selected.

If a valid date and timeframe is selected and there are suffusing capacity only then can a user continue to order review.

✨ Feature request
Status

Active

Version

1.1

Component

User interface

Created by

πŸ‡ΏπŸ‡¦South Africa vlooi vlerke

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @vlooi vlerke
  • πŸ‡²πŸ‡©Moldova andrei.vesterli Chisinau

    Hi @Vlooi Vlerke

    Thx for your input. Will you provide a patch?

    If not, I can take this one but not right now. I have some other priorities.

    Regards
    Andrei

  • πŸ‡ΏπŸ‡¦South Africa vlooi vlerke

    Hi Andrei

    I don't have that type of skills. And D10 has a new way using ajax.
    I have no use for this module, I was just playing around. I build a bookable commerce site in D7 years ago and was just wondering what is new. I was looking at some other booking modules and what I like about your module is the way the timeslots are used inside commerce.

    Commerce offers views for Cart display, Order Summery...

    I was thinking if your widget could have an option to select a view to display timeframes available rather than a select widget?

    Then developers can create selectable timeframes that looks like this using Calendar Views β†’ or Views Simple timeline β†’

    Or just a simple HTML list of timeframes grouped by Timeslot dates.
    Fields: Timeslot date, Timeframes, Capacity and a book button field
    Filters: Timeslot, Timeslot date, Timeframes. (the date and time can the be filtered like +2 days, or +12 hours, to show only what is available in the next few days or hours)

    Is Timeslot Bookings page generated by views?
    I tried to look at a way to relate timeslots in commerce order views and order item views but was unsuccessful.
    This is unrelated to the widget. I was just looking at how this module works.
    E.g show a list to store owner 2 of order items (products) belonging to him to prepared for pickup before timeframe starts.

    You would be able to create shuttle bookings to Tea time sandwich deliveries
    Maybe even book a seat in a theater

    I can help test and build some views if you think its worth going the views direction.
    Kind regards
    Paul

Production build 0.71.5 2024