我有正确显示库存数量的问题.
继承人:
<?php
/**
* Loop Price
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $product;
?>
<?php if ( $price_html = $product->get_price_html() ) : ?>
<span class="price">PREIS:<span class="amount"><?php echo $price_html; ?></span></span><p class="stock-m13"><?php get_sku(get_the_ID()); ?></p>
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)
我想向stock-m13 p中的用户显示可用数量,但我只是像"调用未定义函数get_sku()"这样的错误.
我究竟做错了什么?thx任何帮助.
就像标题所说我希望在我的价格之后摆脱小数.
它现在看起来像8.00但它应该是8.
我尝试了trim()和substr($ price_html,1,1)但没有任何反应
我的代码:
<?php if ( $price_html = $product->get_price_html() ) : ?>
<span class="price">PREIS:<span class="amount">
<?php echo $price_html; ?></span></span><p class="stock-m13"><?php echo $product->get_stock_quantity(); ?>stk.</p>
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)
任何想法我如何从价格输出中削减.00(js?操纵mysqli查询?)
编辑:我没有在我的wp/woocommerce后端"删除零"选项(对于那些会问的人)
来自danyo的解决方案:
$price_html = $product->get_price_html();
$new_price = preg_replace('/.00/', '', $price_html);
Run Code Online (Sandbox Code Playgroud)