Biopac loads pricing data via AJAX to allow cached pages to display the correct prices based on a user’s location and/or user info. There are also tags around the price outputs that tell Google to not index the prices.

Most of the functionality is contained in wp-content/plugins/biopac-custom/js-load-data.php. This includes the function for generating HTML elements in which to load the data, and the function for processing each AJAX request. The other primary code is the JavaScript in wp-content/plugins/biopac-custom/js/js-load-data.php.

The scripts also allow other kinds of data to be loaded besides prices. It has the ability to postload the add-to-cart form for variable products, the main header logo, and anything else that we want to code into it. The main header logo is loaded via AJAX so that we can display different logos based on a user’s location (using the biopac_get_custom_page_settings_by_ip function).

The JavaScript file looks for any element with class “biopac-js-load-data”. It parses the data attributes from each element and creates a single AJAX call to retrieve all of the data for all elements that need to be post-loaded. The results are parsed and inserted into their respective HTML containers. There is some special processing for the add-to-cart form, but all of the other calls are standard in the way they handle the AJAX processing.