Instant Search Using Ajax For XT Woo Floating Cart

By Fahad Mahmood

0+ active installationsVersion 1.0.3

Ajax based add to cart button for the combination of Quick Links - WooCommerce Search Plugin by Instant Search + XT Floating Cart for WooCommerce.

Description

Adds an Add to cart button to every product in the Instant Search dropdown. One click adds the product through WooCommerce’s own AJAX endpoint and refreshes the XT Floating Cart, with no page reload.

Works with the combination of:

  • Quick Links – WooCommerce Search Plugin by Instant Search
  • XT Floating Cart for WooCommerce
  • WooCommerce

Features

  • Ajax add to cart straight from the search results
  • Live refresh of the XT Floating Cart after the product is added
  • Loading indicator while the product is being added
  • Lightweight: two small cached files, loaded only when WooCommerce is active

Pro version (optional, plug and play)

The Pro add-on is a single pro folder. If the folder exists inside the plugin directory, Pro features switch on automatically. If it does not exist, the free features simply keep working. Pro adds:

  • Quantity selector inside the search results
  • Smart handling of variable products (sends the shopper to the product page to choose options)
  • Custom button text and an “Added!” confirmation
  • Button colours and width
  • A settings screen

Get the Pro version

Installation

  1. Upload the plugin folder to /wp-content/plugins/, or install it from the Plugins screen.
  2. Activate the plugin. WooCommerce must be active.
  3. Search for a product with Instant Search and use the new Add to cart button in the results.
  4. Optional: see Settings > Search Ajax Cart for status information.

To enable Pro, upload the pro folder into /wp-content/plugins/instant-search-using-ajax-for-xt-woo-floating-cart/.

FAQ

Does it need WooCommerce?

Yes. Without WooCommerce the plugin does nothing and shows a notice in the admin area.

Does it work with variable products?

The free version uses WooCommerce’s standard add to cart request, which is meant for simple products. The Pro version redirects shoppers to the product page when options must be chosen.

Will Pro survive a plugin update?

Yes. The plugin copies the pro folder aside before an update and puts it back afterwards (from the first update after 1.0.3).

Does it store any personal data?

No. The plugin does not store or transmit any personal data.

Changelog

1.0.3

  • Tested up to WordPress 7.1.
  • Security: all values coming from the search response are now escaped before they are written into the page; product IDs are validated as integers.
  • Fix: the loading animation never showed because a file path was used where a URL was needed.
  • Fix: JavaScript error in the failure handler ($ was undefined).
  • Fix: script no longer runs, or throws errors, when WooCommerce or the blockUI library is not available.
  • Improvement: CSS and JS moved from inline wp_head output into cacheable files; removed an unneeded upgrade.php include from every page load.
  • Improvement: text domain now matches the plugin slug; added Settings / status screen and WooCommerce notice.
  • Improvement: declared compatibility with WooCommerce HPOS and Cart & Checkout blocks.
  • New: optional plug-and-play Pro add-on (/pro/ folder).

1.0

  • First version [11/05/2022][Thanks to Russ]