如何从woocommerce获取商品的库存数量? [英] How to get the stock quantity of an article from woocommerce?
本文介绍了如何从woocommerce获取商品的库存数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在正确显示库存数量时遇到了一些问题.
i got a little problem with displaying the stock quantity correctly.
这是循环:
<?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; ?>
我想向用户显示库存M13 p中的可用数量,但我只是遇到诸如调用未定义的函数get_sku()"之类的错误.
i want to show the user in the stock-m13 p the available quantity but im just gettin errors like "call to undefined function get_sku()".
我在做什么错? 寻求帮助.
what am i doing wrong? thx for any help.
推荐答案
get_sku是产品类的方法,而不是全局函数:
get_sku is a method of the product class, not a global function:
$product->get_sku()
请注意,这可能只是要获取库存代码,而不是实际数量:
Note that this will just get the stock code, not the actual quantity, perhaps you want:
$product->get_stock_quantity()
编辑以澄清:
<p class="stock-m13"><?php echo $product->get_stock_quantity(); ?></p>
这篇关于如何从woocommerce获取商品的库存数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文