Closed axi closed 4 months ago
@axi Thanks for the contribution! Code here looks fine to me but wondering if you could add more details on the issue that this resolves, just so we can properly test?
I can't remember my usecase but because the product id wasn't passed, I was getting the default check-in time when I needed the custom one.
re-found my usecase. php8.1
A booking has been added to the cart so the product is not 100% available anymore. When I open the product page, the calendar opens and try to find availabilities but there's a PHP warning in the ajax call response and the json response is broken (and loader keep turning):
<br/><b>Deprecated</b>: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated in <b>..../web/app/plugins/woocommerce-accommodation-bookings/includes/class-wc-accommodation-booking-date-picker.php</b> on line <b>165</b>
<br/><br/><b>Deprecated</b>: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated in <b>.......web/app/plugins/woocommerce-accommodation-bookings/includes/class-wc-accommodation-booking-date-picker.php</b> on line <b>165</b><br/>
I guess my "woocommerce_accommodation_booking_get_check_times" filter should also never returns a null :-)
I can't remember my usecase but because the product id wasn't passed, I was getting the default check-in time when I needed the custom one.
@axi to replicate the issue, could you confirm if the following steps are accurate?
woocommerce_accommodation_booking_get_check_times
to set a custom check-in time for the product.I would say:
1) create an Accommodation product
2) Make the filter woocommerce_accommodation_booking_get_check_times
set a custom check-in time for the product. In my case, because no product id was passed, the filter was returning a null
value (I agree it shouldn't). Basically, the bug happens if this filter return null.
3) use the calendar to book a period (clicking "book now")
4) calendar is broken (infinite loader) on page load because of the ajax call to "/?wc-ajax=wc_bookings_find_booked_day_blocks&wc-ajax=wc_bookings_find_booked_day_blocks&product_id=PRODUCT_ID&security=lalala&resource_id=0&min_date=2024-01-19&max_date=2024-02-26
" displays the "strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated
" warning
@dkotter I tried to reproduce this issue by adding a custom check-in time with use of filter woocommerce_accommodation_booking_get_check_times
but unable to reproduce this issue. Could you please help by providing detailed info to reproduce this issue from QA point of view? thanks!
@ankitguptaindia just to be sure, are you trying reproducing with php8.1 (minimum) (https://php.watch/versions/8.1/internal-func-non-nullable-null-deprecation) and with display_errors on ?
@ankitguptaindia just to be sure, are you trying reproducing with php8.1 (minimum) (https://php.watch/versions/8.1/internal-func-non-nullable-null-deprecation) and with display_errors on ?
@axi I can reproduce the issue. Thanks for the help.
Testing Environment -
Test Results - Issue has been fixed with this PR, no warnings and errors appears now. Calendar also works fine after adding the booking to cart.
Next Step- Ready to Code Review(Woo) UAT.
Testing Documentation Status- Use Cases related to this PR/Issue, are added to Critical Flow Wiki Pages:
Thanks guys
Fix missing product id when getting check-in time Apply same code style within file
All Submissions:
Changes proposed in this Pull Request:
Fix missing product id when getting check-in time Apply same code style (call static method) within file
Changelog entry