zoukankan      html  css  js  c++  java
  • 价格微数据 Offer 和 AggregateOffer 的使用方法

    Offer 一词在微数据中仅为出价的意思. OfferAggregateOffer 的作用是为商铺中的某个或者某批产品定义售价信息. 因为我服务的网站售价微数据没搞对, 问了一些人, 也研究了一下. 上次已经讲过 Rating 和 AggregateRating 的使用方法, 本文将分享一下 Offer 和 AggregateOffer 微数据及其常用的一些条目.

    Offer

    Rating 指某个产品的销售情况, 比如某款手机售价多少, 售出数量, 是否仍在售等信息. 以下是 schema.org 上摘取的一段代码示例.

    <div itemscope itemtype="http://schema.org/Product"> 	<span itemprop="name">Microdata Offer</span>   	<div itemprop="offers" itemscope itemtype="http://schema.org/Offer"> 		<span itemprop="price">$65.00</span> 		<link itemprop="availability" href="http://schema.org/InStock" />In stock 	</div>   	<span itemprop="description">An offer to sell an item—for example, an offer to sell a product, the DVD of a movie, or tickets to an event.</span> </div>

    在搜索结果中 Offer 显示如下.

    价格微数据 - Offer

    AggregateOffer

    AggregateRating 继承 Offer, 指的是某个商品在多个商家中的汇总情况, 比如电脑城里同一款电脑, 在不同的商铺会有不同的报价. 以下也是 schema.org 上摘取的一段代码示例.

    <div itemscope itemtype="http://schema.org/Product"> 	<span itemprop="name">Microdata AggregateOffer</span>   	<div itemprop="offers" itemscope itemtype="http://schema.org/AggregateOffer"> 		<span itemprop="lowPrice">$78.00</span> 		<span itemprop="highPrice">$98.00</span> 	</div>   	<span itemprop="description">When a single product that has different offers (for example, the same pair of shoes is offered by different merchants), then AggregateOffer can be used.</span> </div>

    在搜索结果中 AggregateOffer 显示如下.

    汇总价格微数据 - AggregateOffer

    价格和货币单位

    无论是 price, lowPrice 还是 highPrice, 大家留意到价格都是带单位 $ 的, schema.org 里面的例子无一例外. 如果将上述 Offer 例子中的 $65.00 改成 ¥65.00, 则结果显示 65円. 人民币 (CNY) 和日元 (JPY) 都用 ¥ 作为货币单位, 但这是同一个字符. 港币 (HKD) 和 美元 (USD) 也是如此的关系, 咋办?

    Offer 有一个 priceCurrency 条目, 需要填写 ISO 4217 货币代号, 指的是当前货币单位. 而且当 priceCurrency 存在, 将以 priceCurrency 的数值为准作为货币单位. 如下书写, 搜索结果中将显示为 65.00元.

    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer"> 	<span itemprop="price">¥65.00</span> 	<meta itemprop="priceCurrency" content="CNY" /> </div>

    某 Google 工程师曾向我透露, 当 priceCurrency 存在, price 里的货币符号是多余的. 此时, 代码可以如下书写.

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

    除非是页面上不应该显示的内容, 尽量不要使用 meta, 所以最好可以用下面的方式书写.

    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer"> 	<span itemprop="priceCurrency" content="CNY"></span> 	<span itemprop="price">65.00</span> </div>

    lowPrice 和 highPrice

    lowPrice 指同一产品不同报价中的最低价格, highPrice 则是最高价格. 按我的理解, AggregateOffer 不应该用在单个产品里, 比如淘宝上可能有某个产品, 红的卖 12 元, 黑的卖 15 元, 价格会标为 12.00 - 15.00, 这种情况不应该用 AggregateOffer.

    从字面上理解, AggregateOffer 不用于做这种价格处理, 但 price 不支持价格区间. (如果使用 Offer, price 写成 12.00 - 15.00, 那么搜索结果将认为书写错误并且结构不予显示.) 现在希望在搜索结果中显示价格区间唯一的方法就是用 AggregateOffer.

    另外需要注意, 如果使用 AggregateOffer, availability 将会失效, 搜索结果中不会显示 In stock.

    未解决的货币单位

    现在 Offer 貌似并不支持单位, 比如某花店买花, 一朵玫瑰是 $1.00 / piece, 一束花是 $10.00 / bundle, 那在搜索结果看到的可能除了价钱, 其他都一样. 微格式貌似不支持单位, 不知道是否有其他方法解决?

  • 相关阅读:
    (转载)C#控件缩写规范
    ToString()格式和用法大全,C#实现保留两位小数的方法
    C#数字前面如何补0
    (转载)C#语言开发规范
    (转载)C#:Enum、Int和String的互相转换,枚举转换
    [踩坑系列]URLEncode 中对 空格的编码有 “+”和“%20”两种
    [IDEA]IDEA设置注释模板
    [Mybatis]Mybatis 常用标签及功能整理
    [设计模式]静态代理
    记一次java电话面试
  • 原文地址:https://www.cnblogs.com/shihao/p/2558267.html
Copyright © 2011-2022 走看看