LessLens Virtual Try-On for WooCommerce

By lesslens

0+ active installationsVersion 1.0.1

Virtual try-on for eyewear stores: shoppers try your frames on their own face from the product page. Needs a LessLens store key.

Description

LessLens Virtual Try-On puts a “Try on virtually” button on your eyewear product pages, under Add to cart or under the title and price. Shoppers try your frames on their own face right on the product page, in the browser on computers and phones, with nothing to install.

What your store gets

  • A try-on button on the product page, under Add to cart or under the title and price, on the frames you have in 3D. Each frame is matched to its product by the SKU you already use, so nothing changes in your catalogue.
  • Every colour. When a shopper picks another colour, the button switches to that colour. If the try-on is open at that moment and the colour has another 3D model, it closes and the button switches to the new colour. Colours that share the product’s SKU can have a 3D model each, or all show the product’s. Colours and products without a 3D model show no button and stay exactly as they are.
  • The try-on in place of the product photo. On a computer, it opens right where the product photo was, so the price, the colours and Add to cart stay in view. This includes galleries that fade from one photo to the next.
  • A photo with the frame on. Shoppers can take one and share or save it. If the camera isn’t available, they can try frames on a photo instead; the photo stays in the browser.
  • Your theme as it is. Classic and block themes: the button goes under Add to cart or under the title and price by itself, or wherever you put the [lesslens_tryon] shortcode.
  • Test mode. Check the try-on on your live store before shoppers see it: only a browser tab opened with ?lltest=1 shows the button, and nothing is loaded from LessLens for anyone else.
  • Fast product pages. The try-on itself loads only when a shopper points at or taps the button. Pages other than product pages get nothing.
  • Your own analytics. Button views, try-on openings, try-ons and kept try-on photos as events on your page, and in Google Tag Manager’s dataLayer if you switch it on.
  • Private by design. The camera image is processed on the shopper’s device. LessLens doesn’t receive or store camera images, and the try-on sets no cookies.

A LessLens store key is required

This plugin connects your store to the LessLens virtual try-on service. The try-on, the 3D models of your frames and your store key come from LessLens with a pilot or a plan: see LessLens for WooCommerce and plans and pricing.

Until a store key is saved (it starts with pk_), the plugin adds nothing to your pages and nothing is loaded from LessLens.

External services

This plugin relies on the LessLens virtual try-on service of LessLens Inc., served from cdn.lesslens.app (hosted on Cloudflare). Nothing is sent from your WordPress server, and nothing is loaded in wp-admin. The requests below are made by the shopper’s browser, after you have saved a store key, on every single product page that gets a try-on placeholder: every product with a SKU and every variable product (a product with colours), whether or not that frame is in your LessLens catalogue. The service answers which of the page’s frames your store can show; the others get no button. To keep LessLens off some products, use the lesslens_tryon_show_button filter (see the FAQ). With test mode on, they are made only in a browser tab opened with ?lltest=1; in every other tab nothing is loaded from LessLens.

What is sent, and when:

  • When such a product page loads: the browser loads the LessLens script (https://cdn.lesslens.app/tryon/v2/tryon-button.js) and asks the service which of the page’s frames your store may show. That request carries your store key, the frame names (made from the product’s and its colours’ SKUs; for a colour without a SKU of its own, or with the product’s SKU, from the product’s SKU and the colour, such as ab-1234-gold) and your store’s address (the page’s origin). Once the service has answered, the request is repeated every 5 minutes while the page is in view and when the shopper comes back to the tab, and it is made again for each newly picked colour. For a colour named from the product’s SKU, if your catalogue doesn’t have that frame, the product’s own frame is asked about next (once per page). A variable product without a SKU of its own loads the script but makes this request only when a colour with a SKU is picked or preselected.
  • When the shopper points at, focuses or taps the button: the public try-on files (the face-tracking model and lighting) are downloaded from cdn.lesslens.app.
  • When the shopper opens the try-on: the browser starts a try-on session (sending a short-lived ticket and the frame name) and downloads the try-on and your frame’s 3D model from cdn.lesslens.app through links that expire within minutes.
  • With every request: as on any website, the shopper’s IP address and browser user agent reach the service. LessLens counts button views and try-ons by frame, with the device type (from the user agent), the country (from the IP address) and your store’s domain, to run the service and for your store’s report. IP addresses are used only to stop abuse and are not stored. No cookies and no visitor IDs are used.
  • Never sent: the camera turns on only after the shopper starts the try-on and allows it. The camera image is processed on the shopper’s device and is never sent to LessLens or anyone else, and neither are face data or measurements. A photo the shopper takes with the frame on goes only where they send it (their share sheet or downloads). A photo the shopper tries frames on instead of the camera stays in the browser. A pupillary distance the shopper types in stays in the browser tab and is passed only to your page.

The try-on window shows a small “Try-on by LessLens” link to business.lesslens.com. It is shown for every store key, pilots included; only stores on the Scale or Custom plan can ask LessLens to turn it off. The plugin has no setting for it.

The analytics events stay on your page; with the dataLayer option on, they also go to your Google Tag Manager, not to LessLens.

  • Terms of use: https://business.lesslens.com/terms
  • Privacy policy: https://lesslens.com/privacy
  • Data and security: https://business.lesslens.com/security

Installation

  1. Install and activate the plugin. WooCommerce must be active.
  2. Go to WooCommerce → Settings → LessLens Try-On, paste your store key (it starts with pk_) and save. A value that isn’t a store key is saved with a warning, and product pages stay as they are until the key is right.
  3. Open a product whose SKU is one of your frames in LessLens: the button is under Add to cart (or under the title and price, if you choose that under “Button position”).

To check the try-on on your live store before shoppers see it, turn on “Test mode” in the same settings before you save the key (see the FAQ).

The key works only on the domains LessLens has on file for your store, so tell us every domain the store uses (for example with and without www, or a staging site). The store must be on HTTPS: the service accepts http:// only on localhost, for testing.

Used the LessLens code snippet before the plugin? Remove the snippet first (see the FAQ).

FAQ

I don’t have a store key. What happens?

Nothing: without a key the plugin adds nothing to your pages and nothing is loaded from LessLens. You get a key from LessLens with a pilot or a plan, together with the 3D models of your frames. See LessLens for WooCommerce.

Which products show the button?

Products whose SKU matches a frame in your LessLens catalogue. The plugin turns the SKU into the frame’s name: lower case, with anything other than letters, digits, “.”, “_” and “-” replaced by “-” (SKU “AB 1234/Gold” becomes ab-1234-gold). LessLens sets up your frames under these names, so you don’t change your SKUs. Products without a SKU, and products whose frame isn’t in 3D yet, show no button and stay exactly as they are.

The LessLens script itself loads on every product page with a SKU and on every variable product, and asks the service about the page’s frames (see “External services”); that is how it finds out which of them have a button.

Can I show the button on some products only?

Yes, with the lesslens_tryon_show_button filter. It gets true and the product; return false and that product page gets no button, and nothing is loaded from LessLens on it. For example, only products in the “Sunglasses” category (slug sunglasses), in your child theme’s functions.php or a code-snippets plugin:

add_filter( 'lesslens_tryon_show_button', function ( $show, $product ) {
    return $show && has_term( 'sunglasses', 'product_cat', $product->get_id() );
}, 10, 2 );

What about frames in several colours?

Each colour has its own 3D model, named by the variation’s SKU. When a shopper picks a colour, the button switches to it. If the try-on is open at that moment and the new colour has another 3D model, it closes (and its camera stops), and the shopper opens it again on the new colour with the button. A colour without a 3D model shows no button. When the page opens on a preselected colour (the product’s default colour, or one in the link), the button starts on that colour; otherwise it shows the frame of the product’s own SKU, if there is one, until a colour is picked.

My colours have no SKU of their own, or share the product’s SKU. What then?

Such a colour is named by the product’s SKU and the colour: the colour’s attribute values (for an attribute set up under Products → Attributes, the value’s slug), in the alphabetical order of the attributes, joined with “-“, made into a frame name as the SKU is. Product SKU “AB-1234” in the colour Gold becomes ab-1234-gold; with a second attribute, such as the size Large, ab-1234-gold-large. LessLens sets up a colour’s 3D model under that name. If your catalogue has no model under that name, the button shows the product’s own frame instead, so a store with one 3D model for all colours of a product keeps its button, as before, on every colour.

Can the button go under the title and price?

Yes. In WooCommerce → Settings → LessLens Try-On, set “Button position” to “Under the title and price”. In classic themes the button then goes into WooCommerce’s product summary, right after the price (before the short description). In block themes it goes right after the Product Price block of the Single Product template. If your product page has neither, for example a page-builder layout, the button stays under Add to cart. For any other place, use the [lesslens_tryon] shortcode (see the next answer).

Can I check the try-on before shoppers see it?

Yes, with test mode. In WooCommerce → Settings → LessLens Try-On, tick “Test mode”, then open a product page with ?lltest=1 at the end of its address (for example https://your-store.com/product/your-frame/?lltest=1). That browser tab shows the button on every product page until you close it. Everyone else gets no button, and nothing is loaded from LessLens for them. The check happens in the visitor’s browser, so it works with page caching. Untick “Test mode” to show the button to all shoppers. If your caching plugin keeps pages for a long time, clear its cache after switching test mode on or off.

Does it work with block themes?

Yes. In block themes such as Twenty Twenty-Five and in classic themes such as Storefront, the button goes under Add to cart (or under the title and price) by itself, with WooCommerce’s “Add to Cart Form” block and with its newer “Add to Cart + Options” block. If your Single Product template has no Add to cart form, or you want the button somewhere else, turn off “Show the button on product pages automatically” and add a Shortcode block with [lesslens_tryon] to the template (Appearance → Editor → Templates → Single Product). The shortcode also works in the product’s short description or description. When you place the shortcode yourself, turn the automatic placement off, and use the shortcode once per page. (With the automatic placement on, the automatic button steps aside only for a shortcode in the product’s description or short description, in the Single Product template’s own content, or one that appears on the page before the automatic button’s place. A shortcode in a template part, synced pattern, widget or page-builder layout that comes after it stays empty, and the automatic button stays.)

Will it slow down my product pages?

On product pages that get a placeholder (see “External services”), the plugin adds the LessLens script as a module, which runs only after the page has been read, and a small script of its own (no libraries) that picks where in your product gallery the try-on opens. Variable products also get a second small script that switches the button to the picked colour. The try-on itself loads only when a shopper points at or taps the button. Other pages get nothing.

Do I need to change my caching or JavaScript optimisation plugin?

Usually not. Page caching is fine. Autoptimize and W3 Total Cache leave the LessLens script alone, and the plugin keeps it out of SiteGround Speed Optimizer’s “Combine JavaScript Files” and out of WP-Optimize’s JavaScript minifying, merging and “Delay JavaScript”, so the button works with those options on. One exception: in WP-Optimize, leave “Contain each included file in its own block” off (it is off unless you turn it on); with it on, the button doesn’t show.

With another optimiser (WP Rocket, LiteSpeed Cache, Perfmatters and the like), if the button doesn’t show, exclude cdn.lesslens.app (the script tryon-button.js) from its “combine”, “minify”, “delay” or “defer” JavaScript options. The LessLens script finds the LessLens service from its own address, so a copy combined into another file or served from your own site doesn’t work, and a delayed one shows the button only after the shopper first scrolls or moves the mouse.

Does my store need HTTPS?

Yes. The LessLens service accepts only pages on https:// (plain http:// only on localhost and 127.0.0.1, for testing), and only on the domains LessLens has on file for your store.

I used the LessLens code snippet before. What now?

Remove the snippet (in Code Snippets, WPCode or your child theme’s functions.php) before you activate the plugin, then save your store key in the plugin’s settings. Your key and frames stay the same. While the snippet is still active, the plugin adds nothing to product pages, so shoppers never get two buttons, and a notice in wp-admin reminds you to remove it.

Can I measure the effect?

Yes. The try-on fires these events on your page (on window) for your own analytics: lesslens:view (the button is shown, once per frame per page), lesslens:open (the try-on is opened), lesslens:tryon (the frame is on the face, from the camera or a photo) and lesslens:photo (the shopper shares or saves a try-on photo). With “Send try-on events to the dataLayer” on, Google Tag Manager gets them as lesslens_view, lesslens_open, lesslens_tryon and lesslens_photo, with the frame in lesslens_model. (The LessLens script also has lesslens_holdout, for an A/B test that holds the button back; the plugin doesn’t set up such a test, so it doesn’t fire.) A pupillary distance the shopper types in comes as lesslens:pd on your page only, never in the dataLayer. LessLens also sends you a monthly report of button views and try-ons by frame.

Do shoppers’ camera images leave their device?

No. The camera image is processed on the shopper’s device, and LessLens doesn’t receive or store it. See “External services” above for everything the try-on sends.

Screenshots

Changelog

1.0.1

  • New: “Button position” setting. The button goes under Add to cart (as before) or under the title and price, in classic and block themes.
  • New: test mode. Only a browser tab opened with ?lltest=1 shows the button; everyone else gets nothing from LessLens. Works with page caching.
  • New: colours without a SKU of their own, or with the product’s SKU, can have a 3D model each, named by the product’s SKU and the colour. Without one, they show the product’s frame, as before.
  • Fix: in product galleries that fade from one photo to the next, the try-on opens over all the photos instead of inside the first one. The theme’s photo zoom no longer reacts under it, and a thumbnail click no longer hides it. The gallery’s arrows are hidden while it is open. The same for a gallery of one photo.

1.0.0

  • First release: the try-on button under Add to cart, colour switching, the [lesslens_tryon] shortcode, the dataLayer option and the lesslens_tryon_show_button filter. Keeps the LessLens script out of SiteGround Speed Optimizer’s JavaScript combining and out of WP-Optimize’s JavaScript processing and delay, and hides WooCommerce’s photo zoom icon while the try-on is open, so it doesn’t cover the try-on’s close button.