How to Embed a Widget on WooCommerce
WooCommerce is the most popular open-source e-commerce platform, powering over 30% of all online stores. By embedding Embeddy widgets on your WooCommerce store, you can add interactive calculators, product configurators, quizzes, lead forms, and more — using the familiar WordPress editor. This guide covers three methods: the Custom HTML block, a reusable shortcode, and direct PHP template editing.
On this page
Prerequisites
Before you start, have the following ready:
- Your Embeddy embed code. Log in at https://embeddy.ai/dashboard, open your widget, and copy the iframe embed code:
<iframe src="https://embeddy.ai/webhost/WIDGET_ID?widget_props_id=PROPS_ID" width="100%" height="500" frameborder="0" ></iframe>
- WordPress admin access. You need an Administrator or Editor role to add Custom HTML blocks and edit pages.
- WooCommerce installed and active. These instructions work with WooCommerce 5.0+ and WordPress 5.9+ with the Block Editor (Gutenberg) enabled.
If you use the Classic Editor: Switch the editor to "Text" mode (not "Visual") before pasting HTML. The Visual editor may strip or modify iframe tags. Alternatively, install the Block Editor (Gutenberg) for the best experience.
Method 1: Custom HTML Block
Easiest — no code required
The WordPress Block Editor (Gutenberg) includes a built-in Custom HTML block that renders raw HTML exactly as entered. This is the simplest way to embed an Embeddy widget on any WooCommerce page or post.
- 1
Open the page or post editor
In your WordPress admin, go to Pages or Posts and edit the page where you want the widget to appear. You can also create a new page.
- 2
Add a Custom HTML block
Click the + button to add a new block. Search for "Custom HTML" and select it. A text area will appear in the editor.
- 3
Paste your embed code
Paste your Embeddy iframe embed code into the Custom HTML block. You can click the "Preview" tab in the block toolbar to see a live preview.
<div style="max-width: 800px; margin: 2rem auto;">
<iframe
src="https://embeddy.ai/webhost/WIDGET_ID?widget_props_id=PROPS_ID"
width="100%"
height="500"
frameborder="0"
style="border: none; border-radius: 8px;"
loading="lazy"
title="Interactive Widget"
></iframe>
</div>- 4
Update or publish
Click "Update" (for existing pages) or "Publish" (for new pages). Visit the live page to confirm the widget appears.
Tip: You can also use the "Embed" block type in Gutenberg. However, the Custom HTML block gives you full control over the iframe attributes and surrounding wrapper HTML.
Method 2: Reusable Shortcode
Intermediate — requires functions.php edit
For a reusable solution, create a WordPress shortcode that outputs your Embeddy widget. You can then use the shortcode on any page, post, or even in WooCommerce product descriptions — without pasting the full iframe code each time.
- 1
Add the shortcode to functions.php
In your WordPress admin, go to Appearance > Theme File Editor and open
functions.php. Add the following code at the end of the file:
// Embeddy Widget Shortcode
function embeddy_widget_shortcode( $atts ) {
$atts = shortcode_atts( array(
'widget_id' => '',
'props_id' => '',
'height' => '500',
), $atts, 'embeddy' );
if ( empty( $atts['widget_id'] ) || empty( $atts['props_id'] ) ) {
return '<!-- Embeddy: missing widget_id or props_id -->';
}
$src = esc_url( 'https://embeddy.ai/webhost/' . $atts['widget_id'] . '?widget_props_id=' . $atts['props_id'] );
$h = intval( $atts['height'] );
return '<div style="max-width:800px;margin:2rem auto;">'
. '<iframe src="' . $src . '" width="100%" height="' . $h . '" frameborder="0" style="border:none;border-radius:8px;" loading="lazy" title="Interactive Widget"></iframe>'
. '</div>';
}
add_shortcode( 'embeddy', 'embeddy_widget_shortcode' );- 2
Use the shortcode anywhere
Now you can embed your widget on any page or post using a simple shortcode:
[embeddy widget_id="YOUR_WIDGET_ID" props_id="YOUR_PROPS_ID" height="500"]
Tip: Use a child theme or a code-snippets plugin (like WPCode) instead of editing your theme's functions.php directly. This prevents your shortcode from being lost during theme updates.
Method 3: Edit WooCommerce PHP Templates
Advanced — requires PHP knowledge
For automatic embedding on every product page (or other WooCommerce templates), you can use WooCommerce's template override system or action hooks. This is the most powerful approach for developers who want widgets to appear automatically on specific templates.
- 1
Use a WooCommerce action hook
Add the following to your child theme's
functions.phpto inject a widget after the product summary on every product page:
// Add Embeddy widget after WooCommerce product summary
add_action( 'woocommerce_after_single_product_summary', 'embeddy_product_widget', 15 );
function embeddy_product_widget() {
echo '<div class="embeddy-widget-wrapper" style="max-width:800px;margin:2rem auto;">
<iframe
src="https://embeddy.ai/webhost/WIDGET_ID?widget_props_id=PROPS_ID"
width="100%"
height="500"
frameborder="0"
style="border:none;border-radius:8px;"
loading="lazy"
title="Interactive Widget"
></iframe>
</div>';
}- 2
Save and verify
Save the file and visit any product page on your store. The widget will appear below the product summary section.
Useful WooCommerce hooks for widget placement:woocommerce_before_single_product — top of product pagewoocommerce_after_single_product_summary — after summary/add-to-cartwoocommerce_after_single_product — bottom of product page
Embedding on Product Pages
WooCommerce product pages are ideal for embedding interactive widgets. Common use cases:
- Size guides — interactive size calculators for clothing and footwear
- Product configurators — visual customization for engraving, colors, etc.
- Compatibility checkers — verify parts fit together before purchase
- Savings calculators — show ROI for high-value products
For all product pages, use Method 3 with WooCommerce action hooks. For specific products only, use Method 2 (shortcode) and paste the shortcode into the product's long description field.
Troubleshooting
The iframe is stripped when I save the page
The WordPress Visual editor (TinyMCE/Classic Editor) may strip iframe tags. Switch to the "Text" tab or use the Block Editor's Custom HTML block instead. Security plugins like Wordfence or iThemes Security may also filter iframes — check their settings.
The widget shows a blank area or loading spinner
Verify your Widget ID and Props ID are correct. Copy the embed code fresh from the Embeddy dashboard and ensure your widget is published.
Widget is blocked by a security plugin
Some WordPress security plugins block external iframes by default. Check your security plugin settings and add embeddy.ai to the allowlist. If using Cloudflare, ensure the frame-src CSP header permits embeddy.ai.
Shortcode shows as plain text
Make sure you added the shortcode function to your active theme's functions.php (or child theme). If the shortcode appears as literal text, the function was not registered. Also ensure there are no PHP syntax errors in the file.
Widget is cut off on mobile
Ensure the iframe has width="100%" and is wrapped in a responsive container. Add max-width: 100%; overflow: hidden; to the wrapper div.
Frequently Asked Questions
Will an embedded widget slow down my WooCommerce store?
No. Iframes load independently of your main page and do not block rendering. Using loading="lazy" ensures the iframe only loads when scrolled into view, preserving your Core Web Vitals scores.
Does this work with page builders like Elementor or WPBakery?
Yes. Both Elementor and WPBakery include HTML/Code widgets. In Elementor, use the "HTML" widget. In WPBakery, use the "Raw HTML" element. Paste the same iframe code. Alternatively, use the shortcode method (Method 2) with any page builder's shortcode element.
Can I embed different widgets on different products?
Yes. Use the shortcode method and paste a different shortcode (with a different widget_id) into each product's description. For a more advanced approach, use custom fields (ACF) to store widget IDs per product and render them dynamically via a template hook.
Ready to supercharge your WooCommerce store?
Build a free interactive widget — calculator, product configurator, quiz, or anything you need — and embed it on your store in minutes.
Create your free widget at embeddy.ai