1

We have a content type called product which has a custom "input" button that allows you to "add to cart". So I have this:

<input type="submit" value="Buy Now $'.$content['field_price'][0]['#markup'].'" alt="Buy Now $'.$content['field_price'][0]['#markup'].'" />

The problem is that the price field is inside an input field, and therefore not displayed, so I would have to show the price some other way to include it within the product page.

The sample that I have shows the price on the page, but I don't want to show the price, because it's already shown in my input field. So this won't work:

<div itemscope itemtype="http://schema.org/Product">
  <span itemprop="name">Kenmore White 17" Microwave</span>
  <img src="kenmore-microwave-17in.jpg" alt='Kenmore 17" Microwave' />
  <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    <span itemprop="price">$55.00</span>
    <link itemprop="availability" href="http://schema.org/InStock" />In stock
  </div>
</div>

The only way I see this working is I do something sneaky like this:

  <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    <span itemprop="price" style="displaY: none;">$55.00</span>
  </div>

Would that be allowed or is that not going to solve my problem?

UPDATE

This works:

<div itemscope itemtype="http://schema.org/Product">
    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        <span itemprop="price" style="displaY: none;">$55.00</span>
    </div>
</div>

This doesn't:

<div itemscope itemtype="http://schema.org/Product">
    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
      <meta itemprop="price" itemprop="55.00" />
      <meta itemprop="priceCurrency" itemprop="USD" />
    </div>
</div>

enter image description here

rockstardev
  • 13,479
  • 39
  • 164
  • 296

1 Answers1

1

You should use the meta element.

In HTML5+Microdata (as well as in HTML+RDFa) the meta element may be used in the body element, exactly for this purpose. It’s the same idea as using the link element for the availability property (like in your example).

In Microdata, it could look like this:

<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
  <meta itemprop="price" content="55.00" />
  <meta itemprop="priceCurrency" content="USD" />
</div>
Community
  • 1
  • 1
unor
  • 92,415
  • 26
  • 211
  • 360
  • Doesn't work. I tried adding it here: https://developers.google.com/structured-data/testing-tool/ ... I'll update my question with more info. – rockstardev Oct 14 '15 at 16:42
  • 1
    @coderama: Sorry, I had a typo in my example: the second attribute should be `content`, not a duplicated `itemprop`. I corrected it. – unor Oct 14 '15 at 16:49