How to Embed a Widget on OpenCart

OpenCart is a popular open-source e-commerce platform known for its simplicity and extensive extension marketplace. By embedding Embeddy widgets, you can add interactive calculators, product configurators, quizzes, lead capture forms, and more to any page — without building a full OpenCart extension. This guide covers three methods: the built-in HTML Content module, direct theme template editing, and creating an OCMOD extension.

Beginner-Intermediate~8 min readUpdated 2026

Prerequisites

Before you start, have the following ready:

<iframe
  src="https://embeddy.ai/webhost/WIDGET_ID?widget_props_id=PROPS_ID"
  width="100%"
  height="500"
  frameborder="0"
></iframe>
  • OpenCart admin access. You need administrator privileges to manage modules, layouts, and theme files.
  • OpenCart 3.x or 4.x recommended. Older versions (2.x) have a slightly different admin interface but the module concept is similar.

Always back up before editing theme files. Use your hosting panel or FTP to create a backup of your catalog/view/theme/ directory before making changes.

Method 1: HTML Content Module

Easiest — no code required

OpenCart includes a built-in HTML Content module (sometimes called "Custom HTML") that lets you place arbitrary HTML in any layout position. This is the quickest way to embed a widget.

  1. 1

    Install or enable the HTML Content module

    In the admin, go to Extensions > Extensions, filter by Modules, find "HTML Content", and click Install (green + button) if not already installed.

  2. 2

    Add a new module instance

    Click Edit on the HTML Content module, then click "Add Module". Give it a name like "Embeddy Widget".

  3. 3

    Paste embed code in HTML source view

    In the editor, click the "Source" button (or </> icon) to switch to HTML mode. Paste your Embeddy iframe embed code and click Save.

  4. 4

    Assign the module to a layout

    Go to Design > Layouts. Edit the layout for your target page (e.g., Home, Product, or Information). Click "Add Module", select your Embeddy module, and choose a position (Content Top, Content Bottom, Column Left, etc.).

  5. 5

    Save and verify

    Click Save on the layout. Visit your storefront to confirm the widget appears in the correct position.

Tip: OpenCart's CKEditor may strip iframe tags. If your embed code disappears after saving, use the Source view consistently and consider disabling the HTML sanitizer in the editor configuration.

Method 2: Edit Theme Templates Directly

Intermediate — requires basic Twig knowledge

OpenCart uses Twig templates (OpenCart 3.x+). You can embed the widget directly in a template file for precise control over placement.

  1. 1

    Locate your theme template

    Via FTP or your file manager, navigate to catalog/view/theme/your-theme/template/. Common templates include common/home.twig (homepage), product/product.twig (product page), and information/information.twig (info pages).

  2. 2

    Add the embed code

    Open the template file and paste the iframe at your desired location:

{# Embeddy Widget #}
<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>
  1. 3

    Clear the template cache

    In the admin, go to Dashboard and click the blue gear icon, then "Refresh" under Theme. Or delete the contents of system/storage/cache/ manually. Visit the storefront to confirm.

Remember: Theme updates may overwrite your changes. Consider creating a child theme or keeping a separate backup of modified template files.

Method 3: OCMOD Extension

Advanced — survives theme updates

OCMOD is OpenCart's modification system that patches template files without editing them directly. This is the cleanest approach for production stores because it survives theme and core updates.

  1. 1

    Create an OCMOD XML file

    Create a file named embeddy-widget.ocmod.xml:

<?xml version="1.0" encoding="utf-8"?>
<modification>
  <name>Embeddy Widget</name>
  <version>1.0.0</version>
  <author>Embeddy</author>
  <link>https://embeddy.ai</link>

  <file path="catalog/view/theme/*/template/common/home.twig">
    <operation>
      <search><![CDATA[{{ content_bottom }}]]></search>
      <add position="before"><![CDATA[
        <div class="embeddy-widget" 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>
      ]]></add>
    </operation>
  </file>
</modification>
  1. 2

    Upload the OCMOD file

    In the admin, go to Extensions > Installer and upload your .ocmod.xml file.

  2. 3

    Refresh modifications and cache

    Go to Extensions > Modifications and click the blue Refresh button. Then clear the theme cache from the Dashboard. Visit the storefront to verify.

Advantage: OCMOD modifications are non-destructive — they patch template output without changing original files. You can disable or remove them at any time from the admin panel.

Embedding on Product Pages

Product pages are one of the best places for interactive widgets. Common use cases:

  • Size calculators — help shoppers find the right fit
  • Product configurators — let customers customize options interactively
  • Compatibility checkers — verify that accessories work together
  • ROI calculators — show value for premium products

To embed on product pages, use Method 1 and assign the module to the Product layout, or edit product/product.twig directly (Method 2). For the OCMOD approach, target the product template file path.

For product-specific widgets, you can use OpenCart's product description field to embed different widget codes per product.

Troubleshooting

The editor strips my iframe tag

OpenCart's CKEditor strips iframes by default. Always paste in Source view. If iframes are still removed, edit admin/view/javascript/ckeditor/config.js and add config.allowedContent = true; to allow all HTML tags.

Widget shows blank or keeps loading

Verify your Widget ID and Props ID are correct. Copy the embed code fresh from the Embeddy dashboard and confirm the widget is published.

Module does not appear on the storefront

Ensure the module is assigned to the correct layout via Design > Layouts. Also clear the template and modification caches. Check that the module status is set to Enabled.

OCMOD modification does not apply

After uploading the OCMOD file, always click Refresh in Extensions > Modifications. If the search string does not match your theme's template exactly, the modification will silently fail. Verify the search text matches your template file.

Widget is cut off on mobile

Ensure the iframe has width="100%". Add overflow: hidden to the wrapper div and adjust the height for smaller viewports using CSS media queries in your theme's stylesheet.

Frequently Asked Questions

Will embedding a widget slow down my OpenCart store?

Iframes load independently and do not block your page render. Adding loading="lazy" defers loading until the widget scrolls into view. Embeddy uses a global CDN for fast delivery.

Does this work with OpenCart 4.x?

Yes. OpenCart 4.x uses Twig templates and supports modules and layouts just like 3.x. The admin paths may differ slightly, but all three methods work. OCMOD is supported in both versions.

Can I embed different widgets on different pages?

Yes. Create multiple HTML Content module instances, each with a different widget embed code. Then assign each one to different layouts (Home, Product, Category, etc.) via Design > Layouts.

Ready to supercharge your OpenCart store?

Build a free interactive widget — size calculator, product configurator, quiz, or anything you need — and embed it on your store in minutes.

Create your free widget at embeddy.ai