
WooCommerce Actual-Time Product Viewer Documentation
Overview
The WooCommerce Actual-Time Product Viewer plugin shows the variety of customers at the moment viewing a selected product in real-time. It supplies stay updates utilizing AJAX requests and shops view counts in a JSON file.
Options:
- Shows the variety of customers at the moment viewing a product on single product pages and product checklist (store) pages.
- Helps customized CSS settings for font shade, alignment, and font household.
- Gives shortcode help for dynamically displaying the view rely.
- Contains an admin settings web page for managing the plugin configuration.
Set up Information
Step 1: Obtain the Plugin
- Obtain or clone the plugin recordsdata into your WooCommerce web site underneath the
/wp-content/plugins/
listing.
Step 2: Add the Plugin
- Add the
product-viewer
listing to the/wp-content/plugins/
listing by way of FTP or through the use of the WordPress Admin’s plugin add characteristic.
Step 3: Activate the Plugin
- Log in to your WordPress admin dashboard.
- Navigate to Plugins > Put in Plugins.
- Discover WooCommerce Actual-Time Product Viewer within the checklist and click on Activate.
Step 4: Configure the Plugin
- Go to Settings > Product Viewer Settings to regulate the show settings corresponding to enabling/disabling the view rely on single product and store pages, and customizing the CSS properties.
Utilization Directions
Displaying View Counts on Product Pages
- The plugin robotically reveals the variety of customers at the moment viewing a product on the product particulars web page if enabled within the settings.
- For product loops (e.g., store pages), the view rely can be displayed beneath every product in a compact format.
Shortcode:
To show the real-time view rely on a customized web page or template, use the next shortcode:
[rt_product_viewer id=<span class="hljs-string">"PRODUCT_ID"</span>]
If no id
attribute is offered, the shortcode will try and detect the present product ID.
Customized Columns in WooCommerce Admin:
- The plugin provides a customized column labeled “Viewing” within the WooCommerce product checklist, displaying what number of customers are at the moment viewing every product.
Developer Information
The plugin is designed with each ease of use and customization in thoughts. It makes use of customary WordPress hooks, AJAX requests, and JSON knowledge storage. Under are some vital features for builders to notice:
JavaScript (rt-product-viewer.js)
- The JavaScript file initializes on web page load and makes an attempt to detect the product ID.
- It sends periodic AJAX requests each 5 seconds to replace the view rely displayed on the product web page.
- It additionally sends a
beforeunload
occasion when the consumer leaves the web page to replace the server that the consumer is now not viewing the product.
Key Capabilities:
- updateProductViewCount: Sends AJAX requests to retrieve the present variety of viewers for the product.
- beforeunload: Detects when the consumer is leaving the web page and updates the view rely accordingly.
PHP (woocommerce-real-time-viewer.php)
- The plugin registers customized AJAX actions (
rt_update_product_view_count
andrt_leave_product_view
) to replace and handle the product view rely. - The product view counts are saved in a JSON file (
view_counts.json
) and up to date based mostly on consumer classes.
Necessary Capabilities:
- rt_update_product_view_count: Handles the AJAX request to replace the product view rely.
- rt_leave_product_view: Handles the AJAX request when a consumer leaves the product web page, lowering the view rely.
- display_product_view_count: Shows the view rely for a selected product.
- rt_product_viewer_shortcode: Gives a shortcode for displaying view counts in customized templates.
- rt_get_currently_viewing_count: Helper operate to fetch the present view rely from the JSON file.
Admin Settings:
- The plugin supplies a settings web page underneath Settings > Product Viewer Settings the place directors can allow/disable the view rely show for single product pages or product loops, and customise the CSS.
Settings Choices:
- Allow on Single Product Web page: Allows/disables the view rely on particular person product pages.
- Allow on Product Checklist (Store) Pages: Allows/disables the view rely on product archive pages.
- CSS Settings: Customise textual content alignment, font shade, and font household for each single product and product loop views.
CSS Customization:
Builders can simply modify the CSS for displaying the view rely utilizing the choices obtainable within the settings panel or by overriding types immediately within the theme.
JSON File (view_counts.json
)
- The JSON file shops real-time view knowledge with every product’s session data.
- Every product’s view rely is tied to a session, making certain that every consumer is counted solely as soon as throughout their session.
FAQ
1. How usually is the view rely up to date?
The view rely is up to date each 5 seconds by way of an AJAX request.
2. The place is the view rely knowledge saved?
The view counts are saved in a view_counts.json
file positioned within the plugin listing.
3. Can I customise the textual content or look of the view rely show?
Sure, you’ll be able to customise the textual content alignment, font shade, and font household from the settings web page underneath Product Viewer Settings.
4. Is the plugin appropriate with caching plugins?
The plugin might not work as anticipated with aggressive caching. Make sure that your caching plugin excludes the product view rely characteristic or AJAX calls from being cached.
Changelog
- Model 1.0
- Preliminary launch with real-time view rely performance for WooCommerce merchandise.
- AJAX-based updates to the view rely.
- Customized columns in WooCommerce product checklist.
- Shortcode help for dynamic view rely show.