douxi3085 2015-11-24 03:58
浏览 66
已采纳

在Woocommerce产品页面上移动“库存”

I'm trying to move "in stock" just underneath the price rather than after the product short description.

What I don't get is that on my wp-content/plugins/woocommerce/templates/single-product/price.php.

The code seems to do just that :

<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">

<p class="price"><?php echo $product->get_price_html(); ?></p>

<meta itemprop="price" content="<?php echo esc_attr( $product->get_price() ); ?>" />
<meta itemprop="priceCurrency" content="<?php echo esc_attr( get_woocommerce_currency() ); ?>" />
<link itemprop="availability" href="http://schema.org/<?php echo $product->is_in_stock() ? 'InStock' : 'OutOfStock'; ?>" />

But when I'm on my product page, the description somehow comes in between : http://www.taldeak.fr/shop/rugby/pays-de-galles-france-cardiff-26-28-fevrier-2016

I know it's in French but basically price and stock are the only two infos in green. FYI, I'm using the WooCommerce - Gravity Forms Product Add-Ons, in case it's relevant.

If anyone could help, it would be great !! Thanks in advance, G

  • 写回答

1条回答 默认 最新

  • douxian6086 2015-11-24 04:11
    关注

    You have moved your link tag for the itemprop="availablity", which is showing in the html within the itemprop="offers" however you have not moved the actual stock html that is contained within <p class="stock in-stock">

    This is the current content around the code you provided

    <div itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">
        <p class="price"><span class="woocommerce-price-before"><font><font>from € 849 </font></font></span><span class="woocommerce-price-after"> </span></p>
    <meta itemprop="price" content="0">
        <meta itemprop="priceCurrency" content="EUR">
        <link itemprop="availability" href="http://schema.org/InStock">
    </div>
    

    Edit: The stock status is included in two places, depending on whether it is a simple or grouped product:

    wp-content/plugins/woocommerce/templates/single-product/add-to-cart/simple.php line 22

    <?php
        // Availability
        $availability      = $product->get_availability();
        $availability_html = empty( $availability['availability'] ) ? '' : '<p class="stock ' . esc_attr( $availability['class'] ) . '">' . esc_html( $availability['availability'] ) . '</p>';
    
        echo apply_filters( 'woocommerce_stock_html', $availability_html, $availability['availability'], $product );
    ?>
    

    wp-content/plugins/woocommerce/templates/single-product/add-to-cart/grouped.php line 62

    <?php
        echo $product->get_price_html();
    
        if ( $availability = $product->get_availability() ) {
            $availability_html = empty( $availability['availability'] ) ? '' : '<p class="stock ' . esc_attr( $availability['class'] ) . '">' . esc_html( $availability['availability'] ) . '</p>';
            echo apply_filters( 'woocommerce_stock_html', $availability_html, $availability['availability'], $product );
        }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题