覆盖作为输出的默认“缺货”消息<p>
标签,副本:
wp-content/plugins/woocommerce/templates/single-product/add-to-cart/simple.php
至
wp-content/themes/yourtheme/woocommerce/single-product/add-to-cart/simple.php
请参见
edit Woocommerce template files打开复制的文件。在第17至23行,您可以找到以下代码:
<?php
// Availability
$availability = $product->get_availability();
if ($availability[\'availability\']) :
echo apply_filters( \'woocommerce_stock_html\', \'<p class="stock \' . esc_attr( $availability[\'class\'] ) . \'">\' . esc_html( $availability[\'availability\'] ) . \'</p>\', $availability[\'availability\'] );
endif;
?>
在这里,您可以更改
<p>
标记您想要的任何内容。例如,我将其编辑为:
<?php
// Availability
$availability = $product->get_availability();
if ($availability[\'availability\']) :
echo apply_filters( \'woocommerce_stock_html\', \'<div class="stock \' . esc_attr( $availability[\'class\'] ) . \'">\' . esc_html( $availability[\'availability\'] ) . \'</div>\', $availability[\'availability\'] );
endif;
?>
因此,输出为:
<div class="stock out-of-stock">Out of stock</div>
重要链接:
Woocommerce Hooks