dfgoogletryon — AI virtual try-on module (Google Vertex AI)
Installation, creating the Google Cloud project and service account, configuration, how the try-on widget works, GDPR privacy, cost control and troubleshooting for dfgoogletryon.
Overview
dfgoogletryon adds a virtual try-on widget to your PrestaShop 8 and 9 product pages. The customer uploads a photo (or uses their camera) and sees the page’s garment rendered on them, powered by the Google Vertex AI Virtual Try-On generative model. Every call to Google is proxied server-side: the service-account key never reaches the browser. The module includes GDPR consent, no photo storage, the SynthID watermark and cost guardrails.
How is this different from Google Shopping try-on?
Google offers two distinct things that should not be confused:
- Merchant Center apparel try-on — a badge that appears only on Google Search and Google Shopping. It is not embeddable on your store and offers no API for your product page.
- Vertex AI Virtual Try-On — the generative API this module uses. It is the only building block that enables a try-on widget directly on your product pages.
dfgoogletryon relies exclusively on Vertex AI. It is a paid, per-image generative service: each try-on generates one or more images billed by Google.
Requirements
- PrestaShop 8.0 to 9.x
- PHP 8.1, 8.2, 8.3 or 8.4
- PHP extensions:
curl,openssl,gd - A Google Cloud project with billing enabled
- The Vertex AI API enabled on that project
- A service account with the Vertex AI User role and its JSON key
Step 1 — Prepare Google Cloud
- Open console.cloud.google.com and create (or select) a project. Note its Project ID.
- Enable billing on the project (Billing menu).
- Enable the Vertex AI API: search for “Vertex AI API” (
aiplatform.googleapis.com) in the API library and click Enable.
Step 2 — Create the service account
- Go to IAM & Admin > Service accounts.
- Click Create service account and give it a name (for example
tryon-prestashop). - Grant it the Vertex AI User role (
roles/aiplatform.user). - Once created, open it, then Keys > Add key > Create new key > JSON. The JSON file downloads.
This JSON key grants access to Vertex AI on your behalf. Never publish it or commit it to a public repository. The module keeps it server-side and never exposes it to the front office.
Step 3 — Install the module
- Download
dfgoogletryon.zipfrom your customer account. - In the PrestaShop back office: Modules > Module Manager > Upload a module.
- Upload the ZIP and click Install.
- On install, the module stores its default settings and a consent text, then hooks into
displayProductAdditionalInfo(button on the page) andactionFrontControllerSetMedia(asset loading, product page only).
Step 4 — Configure the module
Open the module configuration. Fill in the Google Cloud / Vertex AI section:
- GCP Project ID — the Project ID noted in Step 1.
- Region — the Vertex AI location, for example
us-central1. - Model ID — defaults to
virtual-try-on-preview-08-04(you may also usevirtual-try-on-001). - Service-account JSON key — paste the full contents of the JSON file downloaded in Step 2.
Then click Save & test authentication. The module signs a JWT, obtains an OAuth token and confirms “Authentication OK” if everything is correct.
The OAuth token is cached for about 55 minutes to avoid re-minting it on every try-on. Any change to the credentials automatically clears the cache.
Generation & safety settings
Generation & safety section:
- Images per try-on — 1 to 4 images generated per try-on. Each image is billed by Google.
- SynthID watermark — adds an invisible AI watermark to generated images (recommended).
- Safety setting — filtering level (
block_low_and_above,block_medium_and_above,block_only_high,block_none).block_medium_and_aboveby default. - Person generation —
allow_adultrecommended for an apparel store. - Max generations per session — anti-abuse cap per customer session.
- Cooldown between generations (seconds) — minimum delay between two try-ons in the same session.
Display section:
- Enable widget — turns the widget on or off globally.
- Restrict to category IDs — comma-separated category IDs. Leave empty to show on all products, or list your clothing categories to show the widget only where it makes sense.
- Consent text (GDPR) — the text shown next to the mandatory consent checkbox.
How it works for the customer
- On an eligible product page, a Try it on button appears.
- The customer opens the modal, uploads a photo (JPEG, PNG or WebP) or captures from their webcam.
- The photo is downscaled in the browser (max 1024 px, JPEG) before upload, to cut latency and cost.
- The customer ticks the consent checkbox, then clicks Generate try-on.
- The module sends the photo and the product cover image to Vertex AI, then displays the generated image(s).
Privacy & GDPR
The customer photo is processed in memory and sent to Google for generation, but is never saved to the shop’s filesystem or database. The mandatory, customizable consent checkbox appears before any upload. Adapt the consent text to your privacy policy and mention the transfer to Google.
Cost control
Each generated image is billed by Google according to Vertex AI per-image pricing. To keep costs predictable:
- Set Images per try-on to 1 when starting out.
- Set a reasonable Max generations per session (5 by default).
- Use a Cooldown to prevent generation spam.
- Restrict the display to clothing categories via Restrict to category IDs.
A per-product token and same-origin checks discourage use of the proxy outside your pages. This is not strong authentication, but a cost guardrail combined with the caps above.
Product image best practices
The module sends the product cover image as the garment reference. Try-on quality is much better with a clean garment packshot (neutral background, garment clearly visible) than with a lifestyle photo already worn on a model. Tops, bottoms and one-pieces (dresses) give the best results.
Troubleshooting
- “Authentication failed” on test — check the Project ID, the validity of the JSON key, that the Vertex AI API is enabled, and the service account’s Vertex AI User role.
- No image generated — the request may have been filtered by the safety settings. Try another photo, or loosen Safety setting. Also check your Google Cloud billing balance.
- The button doesn’t appear — check that Enable widget is on and that the product belongs to an allowed category (Restrict to category IDs field).
- Network error / timeout — make sure the server allows outbound HTTPS to
oauth2.googleapis.comandREGION-aiplatform.googleapis.com. - “You have reached the maximum number of try-ons” — the per-session cap has been hit; this is expected. Adjust Max generations per session if needed.
Uninstall
Uninstalling removes the module’s settings, including the service-account key and the cached token. No customer photo is stored by the module, so there is nothing else to clean up.