• Resolved murilocarvalho

    (@murilocarvalho)


    My client’s website is using WooCommerce and the WooCommerce Bookings extension to create reservations.

    On the product page there is a calendar for reservations. I’m using CSS and JS Optimization in addition to the other caching options. One of the first problems I identified, but I believe I solved it, was in the JS Optimization. When checked to use Load JS Delayed, the calendar was not displayed. So I switched to Load JS Deferred, cleared the cache and everything looked normal. However, as the days went by, my client reported that his clients had the calendar in a loop, loading infinitely without showing the available data. I checked the console and got the following error: GET https://clientdomain.com.br/?wc-ajax=wc_bookings_find_booked_day_blocks&…&security=f959cf0944&resource_id=0&min_date=2023-03-11&max_date=2023-04-18 403 jquery.min .js?ver=3.6.1:2

    https://ibb.co/FHTPGpg

    It is an expandable error and within it there are other mentions to jquery.min.js and also to a date-picker.js which in my analysis seems to come from webpack://wc-bookings.[name]/assets/js/date-picker.js and is also coming from a source mapped from frontend.js (file found in wc-bookings extension folder).

    https://ibb.co/QH1nRrH

    In my theory, this seems to be a problem that happens when passing overnight, after 00:00. Some cache that fails to correctly identify the current data.

    I’ve already tried checking the page with /?LSCWP_CTRL=before_optm, excluding some JS files from the Optimization, such as frontend.js and date-picker.js (but it comes from this webpack/mapped, so I don’t know if it’s effective) , in addition to jquery.js and jquery.min.js which is already excluded by default. But I believe that CSS and JS Optimization (Minify, Combine, Load JS Deferred) is not connected with the Cache issue.

    My last attempt at a solution was to go to the Cache > Purge > Scheduled Purge URLs tab and put the product page URL. But I’m not sure if this is really solving the problem, nor if it’s the right way to do it. I hope you can help me.

    Sorry for the English, I’m using the Google translator.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support qtwrk

    (@qtwrk)

    please provide the report number

    you can get it in toolbox -> report -> click “send to LiteSpeed”

    Thread Starter murilocarvalho

    (@murilocarvalho)

    Report number:?QFLOPLIQ

    There it is, but I don’t know if you ask for this number as a type of error log, because I needed to clear the plugin’s cache for the calendar to work again on the client’s site.

    Plugin Support qtwrk

    (@qtwrk)

    is it this https://www.ads-software.com/plugins/mwb-bookings-for-woocommerce/ ?

    if not , please search wc-bookings-booking-form in plugin’s file , looking for the same that contains this string , a few line before it should give a line that generate nonce , please show me that

    Thread Starter murilocarvalho

    (@murilocarvalho)

    No, it’s WooCommerce Bookings from WooCommerce itself…

    I found this in the file wp-content\plugins\woocommerce-bookings\includes\admin\views\html-create-booking-page-2.php

    <div class="wrap woocommerce">
    	<h2><?php esc_html_e( 'Add Booking', 'woocommerce-bookings' ); ?></h2>
    
    	<?php $this->show_errors(); ?>
    
    	<form method="POST" data-nonce="<?php echo esc_attr( wp_create_nonce( 'find-booked-day-blocks' ) ); ?>" id="wc-bookings-booking-form">
    		<table class="form-table">
    			<tbody>
    				<tr>
    					<th scope="row">
    						<label><?php esc_html_e( 'Booking Data', 'woocommerce-bookings' ); ?></label>
    					</th>
    					<td>
    						<div class="wc-bookings-booking-form">
    							<?php $booking_form->output(); ?>
    							<div class="wc-bookings-booking-cost" style="display:none"></div>
    						</div>
    					</td>
    				</tr>
    				<tr valign="top">
    					<th scope="row">&nbsp;</th>
    					<td>
    						<input type="submit" name="create_booking_2" class="button-primary add_custom_booking" value="<?php esc_attr_e( 'Add Booking', 'woocommerce-bookings' ); ?>" />
    						<input type="hidden" name="customer_id" value="<?php echo esc_attr( $customer_id ); ?>" />
    						<input type="hidden" name="bookable_product_id" value="<?php echo esc_attr( $bookable_product_id ); ?>" />
    						<input type="hidden" name="add-to-cart" value="<?php echo esc_attr( $bookable_product_id ); ?>" />
    						<input type="hidden" name="booking_order" value="<?php echo esc_attr( $booking_order ); ?>" />
    						<?php wp_nonce_field( 'create_booking_notification' ); ?>
    					</td>
    				</tr>
    			</tbody>
    		</table>
    	</form>
    </div>

    this in the file wp-content\plugins\woocommerce-bookings\includes\booking-form\class-wc-booking-form.php

    wp_enqueue_script( 'wc-bookings-booking-form', WC_BOOKINGS_PLUGIN_URL . '/dist/frontend.js', array( 'jquery', 'jquery-blockui', 'jquery-ui-datepicker', 'underscore' ), WC_BOOKINGS_VERSION, true );
    		wp_localize_script( 'wc-bookings-booking-form', 'wc_bookings_booking_form', $wc_bookings_booking_form_args );
    		wp_localize_script( 'wc-bookings-booking-form', 'wc_bookings_date_picker_args', $wc_bookings_date_picker_args );
    		wp_enqueue_script( 'wc-bookings-date' );
    
    		// Variables for JS scripts
    		$booking_form_params = array(
    			'cache_ajax_requests'        => 'false',
    			'nonce'                      => array(
    				'get_end_time_html'           => wp_create_nonce( 'get_end_time_html' ),
    				'show_available_month_blocks' => wp_create_nonce( 'show_available_month_blocks' ),
    			),
    			'ajax_url'                   => admin_url( 'admin-ajax.php' ),
    			'i18n_date_unavailable'      => __( 'This date is unavailable', 'woocommerce-bookings' ),
    			'i18n_date_fully_booked'     => __( 'This date is fully booked and unavailable', 'woocommerce-bookings' ),
    			'i18n_date_partially_booked' => __( 'This date is partially booked - but bookings still remain', 'woocommerce-bookings' ),
    			'i18n_date_available'        => __( 'This date is available', 'woocommerce-bookings' ),
    			'i18n_start_date'            => __( 'Choose a Start Date', 'woocommerce-bookings' ),
    			'i18n_end_date'              => __( 'Choose an End Date', 'woocommerce-bookings' ),
    			'i18n_dates'                 => __( 'Dates', 'woocommerce-bookings' ),
    			'i18n_choose_options'        => __( 'Please select the options for your booking and make sure duration rules apply.', 'woocommerce-bookings' ),
    			'i18n_clear_date_selection'  => __( 'To clear selection, pick a new start date', 'woocommerce-bookings' ),
    			'i18n_request_failed'        => __( 'We weren\'t able to get that information. Please contact the store owner for help.', 'woocommerce-bookings' ),
    			'pao_pre_30'                 => ( defined( 'WC_PRODUCT_ADDONS_VERSION' ) && version_compare( WC_PRODUCT_ADDONS_VERSION, '3.0', '<' ) ) ? 'true' : 'false',
    			'pao_active'                 => class_exists( 'WC_Product_Addons' ),
    			'timezone_conversion'        => wc_should_convert_timezone(),
    			'client_firstday'            => 'yes' === WC_Bookings_Timezone_Settings::get( 'use_client_firstday' ),
    			'server_timezone'            => wc_booking_get_timezone_string(),
    			'server_time_format'         => wc_bookings_convert_to_moment_format( wc_bookings_time_format() ),
    			'i18n_store_server_time'     => esc_js( __( 'Store server time: ', 'woocommerce-bookings' ) ),
    		);
    
    		wp_localize_script( 'wc-bookings-booking-form', 'booking_form_params', apply_filters( 'booking_form_params', $booking_form_params ) );

    and this in the file wp-content\plugins\woocommerce-bookings\templates\single-product\add-to-cart\booking.php

    if ( ! $product->is_purchasable() ) {
    	return;
    }
    
    $nonce = wp_create_nonce( 'find-booked-day-blocks' );
    
    do_action( 'woocommerce_before_add_to_cart_form' ); ?>
    
    <noscript><?php esc_html_e( 'Your browser must support JavaScript in order to make a booking.', 'woocommerce-bookings' ); ?></noscript>
    
    <form class="cart" method="post" enctype='multipart/form-data' data-nonce="<?php echo esc_attr( $nonce ); ?>">
    
    	<div id="wc-bookings-booking-form" class="wc-bookings-booking-form" style="display:none">
    
    		<?php do_action( 'woocommerce_before_booking_form' ); ?>
    
    		<?php $booking_form->output(); ?>
    
    		<div class="wc-bookings-booking-cost price" style="display:none" data-raw-price=""></div>
    
    	</div>
    
    	<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
    
    	<input type="hidden" name="add-to-cart" value="<?php echo esc_attr( is_callable( array( $product, 'get_id' ) ) ? $product->get_id() : $product->id ); ?>" class="wc-booking-product-id" />
    
    	<button type="submit" class="wc-bookings-booking-form-button single_add_to_cart_button button alt disabled" style="display:none"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>
    
    <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
    
    </form>
    Thread Starter murilocarvalho

    (@murilocarvalho)

    Just to let you know. It looks like the Scheduled Purge URLs don’t work for the problem… I put /reservas/fixi-restaurante (product page) in the list to purge at 04:00. I just checked (today) and the calendar was looping and with the error in the console, and yesterday I had cleared the cache and the calendar had normalized. I just cleared the cache and it got back to normal, but I’m having to do this every day.

    GET https://fixirestaurante.com.br/?wc-ajax=wc_bookings_find_booked_day_blocks&elementor_page_id=396&product_id=396&wc-ajax=wc_bookings_find_booked_day_blocks&security=3788073548&resource_id=0&min_date=2023-03-13&max_date=2023-04-20 403
    send @ jquery.min.js?ver=3.6.1:2
    ajax @ jquery.min.js?ver=3.6.1:2
    s.ajax.s.ajax @ 95bc3fc3d4e5370caa9c0804979b70ce.js?ver=97174:12
    i.get_data @ date-picker.js:829
    i.create @ date-picker.js:688
    date_picker_init @ date-picker.js:257
    (anonymous) @ date-picker.js:30
    each @ jquery.min.js?ver=3.6.1:2
    each @ jquery.min.js?ver=3.6.1:2
    init @ date-picker.js:25
    (anonymous) @ date-picker.js:1156
    e @ jquery.min.js?ver=3.6.1:2
    t @ jquery.min.js?ver=3.6.1:2
    setTimeout (async)
    (anonymous) @ jquery.min.js?ver=3.6.1:2
    c @ jquery.min.js?ver=3.6.1:2
    fireWith @ jquery.min.js?ver=3.6.1:2
    fire @ jquery.min.js?ver=3.6.1:2
    c @ jquery.min.js?ver=3.6.1:2
    fireWith @ jquery.min.js?ver=3.6.1:2
    ready @ jquery.min.js?ver=3.6.1:2
    $ @ jquery.min.js?ver=3.6.1:2

    the s.ajax.s.ajax @ 95bc3fc3d4e5370caa9c0804979b70ce.js?ver=97174:12 came from wp-content/litespeed/js/95bc3fc3d4e5370caa9c0804979b70ce.js?ver=97174

    Plugin Support qtwrk

    (@qtwrk)

    okay , please try this

    go to Cache -> ESI -> enable ESI , add

    find-booked-day-blocks
    create_booking_notification
    get_end_time_html
    show_available_month_blocks

    into ESI nonce list

    go to page optm -> tuning -> JS exclude and defer JS exclude , add above list into both fields

    then purge all

    Thread Starter murilocarvalho

    (@murilocarvalho)

    Ok, I’ll try the above solution and get back to you soon! Thank you for your attention, I hope this resolves! Please do not close the topic…

    Plugin Support qtwrk

    (@qtwrk)

    sure , will be waiting for your update.

    Thread Starter murilocarvalho

    (@murilocarvalho)

    Hello qtwrk! I waited 2 days, and for now it seems that the problem has been solved! Still, in case the problem returns for some reason, is there an email I can contact you directly or would I need to open a new thread?

    I thank you immensely in advance, I would never have solved or imagined this solution.

    You saved me and saved my client!

    Plugin Support qtwrk

    (@qtwrk)

    glad to know it works out

    you can create a new topic here, or mail to support at litespeedtech.com

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Cache issue with wc-bookings datepicker’ is closed to new replies.