PS PrestaShop Intermediate

Prescription Glasses Module for PrestaShop: installation and setup

Install the module, set up lenses, treatments and frames, understand the feasibility rules and process prescription glasses orders.

Updated Module version 1.1.0

Overview

The dfopticlens module lets you sell prescription glasses on PrestaShop 8 and 9. On a frame page, the customer chooses a lens type, enters the prescription, picks a lens among the indices offered, adds treatments and confirms a summary. The server checks every value, calculates the price and verifies that the correction can be made on the frame. The lens price is added to the frame line through PrestaShop’s native customization, and the prescription follows the order down to the invoice.

Installation

  1. In Modules > Module Manager, click Upload a module and send dfopticlens-1.1.0.zip.
  2. Installation creates the Sell > Optics menu with four pages: Prescriptions, Frames, Lenses and indices, Treatments.
  3. Five lenses (1.50, 1.59 polycarbonate, 1.60, 1.67, 1.74) and seven treatments are created with sample prices. Adjust them before going live.
  4. The upload/dfopticlens/ folder is created and protected by a .htaccess file: prescription files there are never reachable from the web.

Upgrading from 1.0.0: upload the 1.1.0 ZIP over it. The upgrade script adds the new settings and hooks without losing data.

Module configuration

The configuration page (the module’s Configure button) has three blocks.

Prescription entry

  • Cylinder convention sent to the lab: minus cylinder, plus cylinder or kept as written. Customers always type the values from their prescription; transposition happens when saving.
  • Prescription file upload: disabled, optional or required, with a maximum size in MB. Accepted formats: PDF, JPG, PNG, checked by content.
  • Warn when the prescription is older than X years (0 disables).
  • Delete prescriptions of abandoned carts after X days.
  • File upload from the account after ordering: adds the My prescriptions page to the customer account.
  • I do not know my PD option and the average pupillary distance used (63 mm by default). The order is then flagged to check.

Feasibility rules

  • Block lenses that cannot be made: on by default. When off, the order is accepted with a warning.
  • Edging allowance and effective diameter margin when the frame ED is unknown (estimated ED = A + margin).
  • Minimum lens height for progressive lenses (28 mm) and short corridor below (32 mm).
  • Warning thresholds: difference between eyes, decentration per eye, plus power on semi-rimless frames.
  • Target thickness of the recommended lens, centre thickness of minus lenses and edge thickness of plus lenses (drilled or not).

Pricing

  • Prices entered tax included or excluded. The tax rule of the frame product applies to the lenses.
  • Surcharges for high power and high cylinder: threshold in dioptres and amount (0 disables).

Lenses and indices

In Sell > Optics > Lenses and indices, each lens has:

  • a name and a short description shown to customers, in each language;
  • the refractive index, used for the thickness estimate, and the material for the lab sheet;
  • the lens types it is offered for, with a price per pair for each: single vision, progressive, no correction;
  • minimum and maximum sphere and maximum cylinder (absolute value, read in minus cylinder form like manufacturer ranges);
  • the largest blank diameter available (0 disables the check) and whether it can be drilled for rimless frames.

Treatments

In Treatments, each treatment has a price per pair (0 shows it as included). The exclusive group prevents combining two treatments: treatments with the same code, for example tint for photochromic, sun tint and polarised, exclude each other. You can also restrict a treatment to some lenses, for example polarised to indices 1.50 and 1.60.

Frames

A frame links a product, or one of its combinations, to its measurements. The lens block only appears on products with an enabled frame.

Creating a frame

  1. In Frames, click Add a frame, or from the product page, Modules tab, click Add frame measurements.
  2. Search the product by name, reference or ID, then choose All combinations or one combination. A frame set for a combination takes priority.
  3. Enter the type (full-rim, semi-rimless, rimless), lens width A, bridge DBL and lens height B, all required. These are the numbers printed on the temple: 52□18 gives A = 52 and DBL = 18.
  4. Optional: the effective diameter ED (estimated otherwise) and the maximum power the frame accepts.
  5. Tick the lens types offered and, if needed, Sell only with lenses.

With Sell only with lenses, the native cart button opens the lens selection. If a direct cart request still adds the frame alone, the module removes it from the cart.

CSV import and export

The Export CSV button gives a file in the right format. Import accepts semicolons or commas and these columns:

product;combination;frame_type;lens_width;lens_height;bridge;ed;max_power;vision_types;lens_required;active
  • product: product ID or reference; combination: combination ID or reference, empty or 0 for all.
  • frame_type: full, semi or rimless; vision_types: single|progressive|plano.
  • An existing frame (same product and combination) is updated. Rejected lines are listed with their number.

The Resynchronise products button rebuilds the product customization fields, useful if an employee without rights on the module edited products.

Customer flow

  1. Type: single vision, progressive or no correction, depending on what the frame offers. With no correction, the prescription step is skipped.
  2. Prescription: OD / OS grid, pupillary distance as one or two values, date, file and a note for the optician. A logged-in customer can reuse the prescription of a previous order.
  3. Lens: cards with price per pair, cross-section to scale, estimated thickness and a recommended lens. Lenses that cannot be made are greyed out with the reason.
  4. Treatments: treatments unavailable for the chosen lens are greyed out.
  5. Summary: feasibility status, notes, price breakdown and frame plus lenses total.

The entry is kept if the customer reloads the page and cleared after adding to cart.

Feasibility rules

Check Effect
Sphere or cylinder outside the lens range Lens unavailable
Blank diameter needed (ED + 2 × decentration + allowance) above the lens blank Lens unavailable if blocking is on
Rimless frame and material that cannot be drilled Lens unavailable if blocking is on
Height B below the minimum for progressive lenses Blocking (or warning)
Height B below the short corridor threshold Information
Power above the frame maximum Blocking (or warning)
Difference between eyes, strong decentration, high plus power on semi-rimless, old prescription, unknown pupillary distance Warning, order flagged to check

Calculations use the minus cylinder form. Thickness is estimated with the sag formula: it helps compare indices, it is not the lab calculation.

Prices, discounts and invoice

The lens price is stored tax excluded in the customization of the cart line. PrestaShop adds it to the frame price and applies the product’s VAT. If the frame has a percentage reduction (specific price or customer group), PrestaShop applies it to the lenses too: the panel shows the struck-through price and a Frame promotion also applied to the lenses line, so that the displayed total matches the cart.

Orders and lab sheet

  • The back office order page shows one block per prescription: transposed values, lens, treatments, frame measurements, decentration and minimum blank per eye, feasibility notes and price breakdown.
  • Print lab sheet opens an A4 page ready to print.
  • Download prescription file retrieves the scan sent by the customer.
  • Sell > Optics > Prescriptions lists all prescriptions with their status: OK, to check, not feasible.

Customer account: My prescriptions

A customer who ordered lenses sees the My prescriptions link in their account. The page shows each prescription with the related order. If file upload is optional and the customer did not attach it, they can send it from this page; the optician then finds it in the order.

Health data and GDPR

  • Prescription files are stored outside the public folder and can only be downloaded from the back office.
  • Prescriptions of carts that were never ordered are deleted after the set delay, together with the related cart line.
  • With the official psgdpr module, exporting and deleting a customer’s data includes their prescriptions.

Troubleshooting

The lens block does not appear on the product page

Check that the product has an enabled frame and that the theme displays the displayProductAdditionalInfo hook. Clear the PrestaShop cache.

The native cart button does not open the panel on a lenses-only frame

The module intercepts buttons with data-button-action="add-to-cart". If your theme uses another attribute, the server-side block still applies: the frame alone is removed from the cart.

The panel total differs from the cart

A fixed amount reduction only applies to the frame, and a cart rule (voucher) applies to the whole cart: they do not appear in the lens panel.

Was this page helpful?

Still stuck? Contact support