Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

Performance changes in the upcoming Order Delivery Date v9.27.0

Introduction

In the latest release of Order Delivery Date v9.27.0 that is due to release by 2nd week of July, we have made a lot of performance changes.

  1. Removed the unnecessary ajax calls
  2. Used WC Ajax instead of admin-ajax
  3. Used REST API in place of some of the ajax calls.

Removed Unnecessary Ajax calls:

In the previous versions, we used the following ajax calls on the checkout page:

orddd_get_zone_id

    1. Purpose : We used this ajax to fetch the first shipping method in a shipping zone. This would help in loading the custom settings for that shipping method when the page was loaded or when the shipping zone was changed after entering the address. This would also run when a shipping method was changed where it was not necessary.
    2. Triggered on actions: on page load, on change of shipping method
    3. Output: It returned the first shipping method of the shipping zone applied on checkout and the custom settings were applied based on that.

orddd_update_delivery_session

    1. Purpose : This ajax call checks for the common delivery days for custom settings of multiple categories. Although, this is only for the common settings, it was still called on various actions like on change of shipping method, or on selecting the date or even when checkout is updated.
    2. Triggered on actions: on page load, on change of shipping method, after every update_order_review ajax
    3. Output: It returned the common settings to be applied if more than one category product was added with different custom settings.

check_for_time_slot_orddd

    1. Purpose: This ajax is used to check for the available time slots for a given date.This was called when a date was selected.
    2. Triggered on actions: This was called when a date was selected from the calendar.
    3. Output: The available time slots for the selected date.

Changes in new version:

In the latest version of Order Delivery Date, we have removed 2 of these ajax calls i.e orddd_get_zone_id and check_for_time_slot_orddd . The third one i.e orddd_update_delivery_session is converted to WC Ajax and is only called when category based custom settings are applied on checkout.

orddd_get_zone_id was only required on page load or when a shipping zone was changed on the checkout page so that the custom settings for the default selected shipping method could be applied. In place of ajax, we sent all the default shipping methods of each zone to the JS file and there checked for the matching zone. This resulted in much faster loading of the custom settings.

orddd_update_delivery_session ajax was an admin-ajax in the previous version. admin-ajax should not be used on the frontend of a site as it loads a few other core WordPress files in order to be able to serve the request. We converted this to WC Ajax which is specifically used on front end and is much faster than admin-ajax. To further minimize the use of this ajax, we only call it when category based settings are applied on checkout.

For replacement of check_for_time_slot_orddd , we decided to use REST API in place of ajax calls. We created the REST API endpoints to get the settings as well as to get the available timeslots based on the date. REST API’s improve performance and are much faster than the ajax calls.

Here are the REST API endpoints :

  1. http://tychesoftwares.local/wp-json/orddd/v1/delivery_schedule/12 – this would return the custom delivery settings with id 12.
  2. http://tychesoftwares.local/wp-json/orddd/v1/delivery_schedule/?mode=category&category=<category slug> – this would return custom delivery settings for that category
  3. http://tychesoftwares.local/wp-json/orddd/v1/delivery_schedule/?mode=category&category=<category slug>&shipping_method=<method id> – this would return custom delivery settings for that category & shipping method
  4. http://tychesoftwares.local/wp-json/orddd/v1/delivery_schedule/?mode=shipping_method&shipping_method=<method id> – this would return custom delivery settings for that shipping method
  5. http://tychesoftwares.local/wp-json/orddd/v1/delivery_schedule/?mode=pickup_location&pickup_location=<location id> – this would return custom delivery settings for that pickup location
  6. http://tychesoftwares.local/wp-json/orddd/v1/delivery_schedule/?mode=pickup_location&pickup_location=<location id>&category=<category slug> – this would return custom delivery settings for that pickup location & category name
  7. http://tychesoftwares.local/wp-json/orddd/v1/delivery_schedule/12?date=2020-06-20  – this would return the available time slots for the given date in custom delivery settings with id 12.
  8. http://tychesoftwares.local/wp-json/orddd/v1/delivery_schedule/12?number_of_dates=10 – this will return the next 10 available dates for custom settings 12

Performance Changes

Let’s look at the performance difference in the older version and new version.

Only global settings with time slots:

Performance changes in the upcoming Order Delivery Date v9.27.0 - Tyche Softwares

As you can see, it took 4.88s to load all the ajax calls. The 2 admin-ajax calls run here are orddd_get_zone_id & check_for_time_slot_orddd.

Whereas, if you look at the new version:

Performance changes in the upcoming Order Delivery Date v9.27.0 - Tyche Softwares

It took 3.48s to load and only the REST API call is initiated to check for time slots. There is some difference in the load times and number of ajax calls.

Number of ajax calls earlier: 2

Number of ajax calls from v9.27.0: 1 API call

Custom settings with date & time slots:

Performance changes in the upcoming Order Delivery Date v9.27.0 - Tyche Softwares

Performance changes in the upcoming Order Delivery Date v9.27.0 - Tyche Softwares

As we can see, there is a huge difference in terms of loading of custom settings. The load time in the old version is 7 secs while with the new version, it’s 3.54s. There are a lot of ajax calls when custom settings are loaded in the older version. Whereas in the new version, there is only one API call to fetch the time slots.

Number of ajax calls earlier: 7 – 8

Number of ajax calls from v9.27.0: 1 API call

Global settings with only date:

Performance changes in the upcoming Order Delivery Date v9.27.0 - Tyche Softwares

Performance changes in the upcoming Order Delivery Date v9.27.0 - Tyche Softwares

In the previous version, one ajax was called i.e orddd_update_delivery_session when only general settings were applied. This ajax should have been called only when custom settings were applied.

In the new version, as you can see, there is no ajax call happening when custom settings are not present. And the load time is also lesser.

Number of ajax calls earlier: 1

Number of ajax calls from v9.27.0:  0

Custom settings with only date:

Performance changes in the upcoming Order Delivery Date v9.27.0 - Tyche Softwares

Performance changes in the upcoming Order Delivery Date v9.27.0 - Tyche Softwares

As you can see, even with custom settings enabled with only date, there are lots of ajax calls in the previous version whereas none in the new version.

If custom settings are based on product categories, then there will be one ajax call of orddd_update_delivery_session in the new version.

Number of ajax calls earlier: 7

Number of ajax calls from v9.27.0: 0 or 1

Conclusion

These changes will help in the load time and will improve the performance of the website. And with REST API endpoints, there will be a lot of scope in extending the plugin for the store owners.

Because of the multiple ajax calls, the loader would also hinder a smooth experience of the checkout page. now that won’t be the case.


Call for beta testing of Order Delivery Date 9.27.0

We are looking forward to releasing this update by 2nd week of July. We are also looking for volunteers who could help us test the beta copy of the release. Since it is a major release, we want to test it before doing the stable release. This call is for all our existing Order Delivery Date Pro plugin customers! Hit us up in the comments or drop an email to [email protected]. Rashmi is the Product Lead for Order Delivery Date Pro plugin.

Browse more in: Order Delivery Date, Improve Performance, WooCommerce

Share It:

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x