如何将微数据添加到价格字段?

How to add microdata to price field?

我们有一个名为产品的内容类型,它有一个自定义 "input" 按钮,允许您 "add to cart"。所以我有这个:

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

问题是价格字段在输入字段内,因此没有显示,所以我必须以其他方式显示价格以将其包含在产品页面中。

我的示例在页面上显示了价格,但我不想显示价格,因为它已经显示在我的输入字段中。所以这行不通:

<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">.00</span>
    <link itemprop="availability" href="http://schema.org/InStock" />In stock
  </div>
</div>

我看到这个工作的唯一方法是我偷偷摸摸地做这样的事情:

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

是否允许这样做,还是不能解决我的问题?

更新

这个有效:

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

这不是:

<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>

您应该使用 meta 元素。

In HTML5+Microdata (as well as in HTML+RDFa) the meta element may be used in the body element, 正是为了这个目的。它与使用 link 元素为 availability 属性 相同的想法(就像你的例子一样)。

在 Microdata 中,它可能如下所示:

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