woocommerce stock notification priority

一世执手 提交于 2019-12-02 09:22:24

I finally figured it out. Stock status is hardcoded into the templates, so you must first remove it from simple.php and variation.php in your child theme. (And grouped.php too, but I don't use grouped products, so I didn't need to update that template.)

Delete these lines from variation.php

    <div class="woocommerce-variation-availability">
    {{{ data.variation.availability_html }}}
</div>

and this line from simple.php (line 28)

echo wc_get_stock_html( $product );

Then in your functions.php add the following code changing the priority to where ever you want the stock status to show up.

add_action( 'woocommerce_single_product_summary', 'mh_output_stock_status', 21 );

function mh_output_stock_status ( ) {
    global $product;

    echo wc_get_stock_html( $product );

}

I really wish stock was hooked in like the rest of the summary. It would be a lot more straight forward.

I hope this helps someone else.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!