Adding Structured Data to osCommerce for Google Merchant (JSON-LD & Microdata)


Adding Structured Data to osCommerce for Google Merchant (JSON-LD & Microdata)

In this article I explain how to easily add structured data for Google Merchant using both JSON-LD and Microdata.

 Open & edit the correct file

Open up your FTP or IDE and source the file in the following location in the root of your directory you will find a file named product_info.php

oscommerce product_info location

Before you start editing the file, please copy it and rename it to something else, for example : products_info.backup.php

Open the original file and scroll all the way to the bottom of the page.

You will see an opening <?php tag and underneath it two includes which are the template_bottom and application_bottom files.

Before the opening <?php tag place the below code


<script type="application/ld+json">
  "@context": "",
  "@type": "Product",
    "offers": {
    "@type": "Offer",
    "priceCurrency": "<?php echo tep_output_string($currency); ?>",
	"price": "<?php echo preg_replace('/[^0-9.]+/','',preg_replace('/,/','.',$products_price)); ?>",
	"itemCondition" : "",
	"availability" : "<?php if ($product_info['products_quantity'] >= 1){echo 'In Stock';}else{echo 'Out of Stock';} ?>"


<div itemscope itemtype="">
  <meta itemprop="name" content="<?php echo $product_info['products_name'].' '.$product_info['products_model']; ?>" />
  <div itemprop="offers" itemscope="" itemtype="">
    <meta itemprop="priceCurrency" content="<?php echo tep_output_string($currency); ?>">
    <meta itemprop="price" content="<?php echo preg_replace('/[^0-9.]+/','',preg_replace('/,/','.',$products_price)); ?>">
    <meta itemprop="availability" content="<?php if ($product_info['products_quantity'] >= 1){echo 'In Stock';}else{echo 'Out of Stock';} ?>">
    <meta itemprop="itemCondition" itemtype="" content="" />

If you have done it correctly, you should see something similar as to the image below

oscommerce product_info example

Save the file

Checking The Results

You can use Google’s Structured data testing tool, to check if everything is done correctly. The below image shows an example of a correct listing.

Tip :
Copy your landing page link (address bar URL) and paste it in the field for fetching the URL.
Structured Data Testing Tool URL

Google Structured Data Testing Result

Notice :
When you have warnings in your diagnostics tab, remember that it takes up to 30 days before they will disappear, this is because Google does not crawl your landing pages every day but in a span of 30 days.

Need Help?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.