从Woocommerce产品架构中删除价格

时间:2020-07-17 01:52:55

标签: wordpress woocommerce schema

客户正在使用批发价格插件,并且只希望价格可用于登录批发商。该插件似乎工作正常,但价格开始出现在搜索结果中。我编写了以下代码,以从结构化数据段中删除价格:

add_filter( 'woocommerce_structured_data_product_offer', function( $markup_offer, $product ) {

    if( isset( $markup_offer[ 'price' ] ) )
        unset( $markup_offer[ 'price' ] );

    if( $markup_offer[ 'priceSpecification' ][ 'price'] )
        unset( $markup_offer[ 'priceSpecification' ][ 'price'] );

    return $markup_offer;

}, 10 , 2);

该代码仍然有效-价格不在页面底部的<script type="application/ld+json">..</script>中。但是现在我们在标头中的一些标记代码中找到了价格:

<div itemtype='http://schema.org/Product' itemscope>
    <div itemprop='offers' itemscope itemtype='http://schema.org/Offer'>
        <meta itemprop='price' content='22.00' />
        <meta itemprop='priceCurrency' content='AUD' />
    </div>
</div>

价格未显示在Google搜索结果中,但显示在Google图片搜索中。知道如何从产品页面中完全删除价格吗?

0 个答案:

没有答案
相关问题