woocommerce / woocommerce-accommodation-bookings

An accommodations add-on for the WooCommerce Bookings extension.
87 stars 31 forks source link

Availability for Multiple Nights Bookings Fixed | Booking Calendar #405

Closed faisal-alvi closed 4 months ago

faisal-alvi commented 5 months ago

All Submissions:


Changes proposed in this Pull Request:

This PR addresses the availability issue that arises when a booking is made for more than 1 night. The problem was identified in the booking calendar of the bookings-availability extension, where only the first day of the booking was displayed as booked/unavailable, rather than showing all the days that were booked as unavailable.

To illustrate, if a booking was made for the 22nd to the 25th, the calendar previously only marked the 22nd as booked. However, with the fix, it now correctly displays the 22nd, 23rd, and 24th as booked. It's important to note that the 25th is not marked as booked because it is a checkout day, and a new booking is possible on that day.

In technical terms, the plugin previously marked only the days that "contained" the booking as booked (using is_within_block()), but the fix introduced a logic change. Now, it marks all the days that "intersect" with the booking as booked (using is_intersecting_block()).

Closes https://github.com/woocommerce/woocommerce-bookings-availability/issues/554.

Steps to test the changes in this Pull Request:

  1. Create an accommodation product for 3 days (for example 22nd to 25th)
  2. Make a booking for it
  3. Add Booking Calendar to a page and select the accommodation product
  4. See the 22nd, 23rd and 24th days are blocked

Changelog entry

Fix - Booking Calendar displays incorrect availability for Accommodation Products.

faisal-alvi commented 5 months ago

The changed file was not indented correctly, due to which when one line changed in this PR, it started displaying that error. To fix that, I had to change indention of the whole file, that brought more PHPCS errors because the whole file was changed. I skipped further fixes in the current PR, assuming we can handle it in later PRs.

ankitguptaindia commented 5 months ago

@faisal-alvi Thanks for the PR. I found some issues when removing Booking from the cart. Explined the issue with steps and product configuration setting in below screencast. Please have a look and let me know if need any help to reproduce.

https://github.com/woocommerce/woocommerce-accommodation-bookings/assets/6384299/dc0b2803-3df6-4b2f-964b-c6c030e15fcd

faisal-alvi commented 5 months ago

@ankitguptaindia thanks for the report and detailed explanation through video. I feel those 2 issues you mentioned seem to be occurring due to the caching mechanism. Can you please try again by clearing the product-level cache? Happy to connect 1:1 to test this on call.

ankitguptaindia commented 5 months ago

@faisal-alvi I re-checked this issue again and the issue is still happening after re-saving the product settings. Let's meet over a call if you are not able to reproduce issue.

https://github.com/woocommerce/woocommerce-accommodation-bookings/assets/6384299/c0991a43-7fde-4877-a3ab-32adc5ee3be2

ankitguptaindia commented 5 months ago

Thansk @faisal-alvi I checked this by creating a new accommodation product and works fine now.


QA/Test Report-

Testing Environment -

* WordPress: 6.4.2 * Theme: Storefront Version: 4.5.4 * WooCommerce - Version 8.5.2 * PHP: 8.0.22 * Web Server: Nginx * Browser: Chrome - Version 121 * OS: macOS Sonoma 14.3 * Git Branch: fix/avail-554

`

Test Results - The Issue has been fixed and working as expected now.

Functional Demo / Screencast -

https://github.com/woocommerce/woocommerce-accommodation-bookings/assets/6384299/1468598f-f67d-45c7-900a-b8ecbd331e77

Next Step- Ready to Code Review(Woo) UAT

Testing Documentation Status- Cases related to this PR/Issue, are added to Critical Flow Wiki Pages: