FeedArmy Co., Ltd.

Add Structured Data To Opencart 3.x For Google Shopping (JSON-LD & Microdata)

How to add structured data for Google Merchant Center to OpenCart 3, click here for OpenCart 1.5x and 2.x

Login to OpenCart

Login to your admin panel of OpenCart and navigate to Design > Theme Editor

OpenCart 3 Theme Editor

Theme Editor

From your Choose a template, go to product > product.twig

You will now see an editor, paste the code below under {{ header }}, before you do make sure to follow the short edit instructions.

JSON LD

Make sure you change the values highlighted in capitals.

Choose the code where the price decimal matches yours. (US or UK = DOT, Continental Europe = Comma)

Prices with dot decimal

<script type="application/ld+json">
{
  "@context": "http://schema.org/",
  "@type": "Product",
    "offers": {
    "@type": "Offer",
	"name": "{{ heading_title }}",
    "priceCurrency": "REPLACE_WITH_CURRENCY_CODE",
	{% if price %}"price": "{{ price|trim('REPLACE_WITH_CURRENCY_SYMBOL') }}",
    {% else %}"price": "{{ special|trim('REPLACE_WITH_CURRENCY_SYMBOL')}}",{% endif %}
	"itemCondition" : "http://schema.org/NewCondition",
	"availability" : "{{ stock }}"
  }
}
</script>

You should see the code below when you have changed the currency code and symbol.

<script type="application/ld+json">
{
  "@context": "http://schema.org/",
  "@type": "Product",
    "offers": {
    "@type": "Offer",
	"name": "{{ heading_title }}",
    "priceCurrency": "EUR",
	{% if price %}"price": "{{ price|trim('

Prices with comma decimal

<script type="application/ld+json">
{
  "@context": "http://schema.org/",
  "@type": "Product",
    "offers": {
    "@type": "Offer",
	"name": "{{ heading_title }}",
    "priceCurrency": "REPLACE_WITH_CURRENCY_CODE",
	{% if price %}"price": "{{ price|replace({'REPLACE_WITH_CURRENCY_SYMBOL': '', ',' : '.'}) }}",
    {% else %}"price": "{{ special|replace({'REPLACE_WITH_CURRENCY_SYMBOL': '', ',' : '.'}) }}",{% endif %}
	"itemCondition" : "http://schema.org/NewCondition",
	"availability" : "{{ stock }}"
  }
}
</script>

You should see the code below when you have changed the currency code and symbol.

<script type="application/ld+json">
{
  "@context": "http://schema.org/",
  "@type": "Product",
    "offers": {
    "@type": "Offer",
	"name": "{{ heading_title }}",
    "priceCurrency": "EUR",
	{% if price %}"price": "{{ price|replace({'€': '', ',' : '.'}) }}",
    {% else %}"price": "{{ special|replace({'€': '', ',' : '.'}) }}",{% endif %}
	"itemCondition" : "http://schema.org/NewCondition",
	"availability" : "{{ stock }}"
  }
}
</script>

HTML

Make sure you change the values highlighted in capitals.

Choose the code where the price decimal matches yours. (US = DOT, Continental Europe = Comma)

Prices with dot decimal

<div itemscope itemtype="http://schema.org/Product">
  <meta itemprop="name" content="{{ heading_title }}" />
  <div itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">
    <meta itemprop="priceCurrency" content="REPLACE_WITH_CURRENCY_CODE">
    {% if price %}
      <meta itemprop="price" content="{{ price|trim('REPLACE_WITH_CURRENCY_SYMBOL') }}">
    {% else %}
      <meta itemprop="price" content="{{ special|trim('REPLACE_WITH_CURRENCY_SYMBOL') }}">
    {% endif %}
    <meta itemprop="availability" content="{{ stock }}">
    <meta itemprop="itemCondition" itemtype="http://schema.org/OfferItemCondition" content="http://schema.org/NewCondition" />
  </div>
</div>

If your in the US, your code should look like the example below.

<div itemscope itemtype="http://schema.org/Product">
  <meta itemprop="name" content="{{ heading_title }}" />
  <div itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">
    <meta itemprop="priceCurrency" content="USD">
    {% if price %}
      <meta itemprop="price" content="{{ price|trim('

Prices with comma decimal

<div itemscope itemtype="http://schema.org/Product">
  <meta itemprop="name" content="{{ heading_title }}" />
  <div itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">
    <meta itemprop="priceCurrency" content="REPLACE_WITH_CURRENCY_CODE">
    {% if price %}
	  <meta itemprop="price" content="{{ price|replace({'REPLACE_WITH_CURRENCY_SYMBOL': '', ',' : '.'}) }}">
    {% else %}
	  <meta itemprop="price" content="{{ special|replace({'REPLACE_WITH_CURRENCY_SYMBOL': '', ',' : '.'}) }}">
    {% endif %}
    <meta itemprop="availability" content="{{ stock }}">
    <meta itemprop="itemCondition" itemtype="http://schema.org/OfferItemCondition" content="http://schema.org/NewCondition" />
  </div>
</div>

If your in Europe, your code should look like the example below.

<div itemscope itemtype="http://schema.org/Product">
  <meta itemprop="name" content="{{ heading_title }}" />
  <div itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">
    <meta itemprop="priceCurrency" content="REPLACE_WITH_CURRENCY_CODE">
    {% if price %}
	  <meta itemprop="price" content="{{ price|replace({'€': '', ',' : '.'}) }}">
    {% else %}
	  <meta itemprop="price" content="{{ special|replace({'€': '', ',' : '.'}) }}">
    {% endif %}
    <meta itemprop="availability" content="{{ stock }}">
    <meta itemprop="itemCondition" itemtype="http://schema.org/OfferItemCondition" content="http://schema.org/NewCondition" />
  </div>
</div>

You should see something like the image below

Now save and check the landing page for any errors.

Testing the results

Verify that you have done it correctly by checking the page with Google’s Structured Data Testing Tool

Please note the data testing tool, only checks for syntax errors, not for policy checks. However, if you add the code as is, then you are withing Google Shopping policy requirements.

Exit mobile version