繁体   English   中英

如何在WooCommerce中为CSS数量分配CSS类?

[英]How to assign a CSS class to the Stock Quantity in WooCommerce?

我正在尝试以以下格式显示“库存数量”文本。

“有多少库存?” “20”

您可以通过以下链接实时查看它:

https://spendr.dk/shop/

我正在使用以下代码。

add_action('woocommerce_after_shop_loop_item','bbloomer_show_stock_shop', 10);

function bbloomer_show_stock_shop() {
global $product;
if ( $product->stock ) { // if manage stock is enabled 
if ( number_format( $product->stock,0,'','' ) < 3 ) { // if stock is low
echo '<div class="remaining">Only ' . number_format($product->stock,0,'','') . ' left in stock!</div>';
} 

else {
echo '<div class="remaining">' . 'How many in stock?</div>' . 
number_format($product->stock,0,'','');
}
}
}

现在,我要调整“库存数量”(例如:20)。 我正在尝试将CS​​S类添加到库存数量中。 我想在“有多少库存?”旁边显示它。 文本。

如何在库存数量中添加CSS类? 在PHP中。

谢谢。

首先,修改剩余课程的样式

.remaining { display: inline-block; } .remaining { display: inline-block; }

第二,用span代替div

<div class="uniqstock"> 20</div><span class="uniqstock"> 20</span>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM