Php wordpress的商业价格是错误的
我正在尝试为我的woocommerce中的所有产品创建一个简单的xml 我已经构建了其中的大部分,但我无法获得当前的产品价格:Php wordpress的商业价格是错误的,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,我正在尝试为我的woocommerce中的所有产品创建一个简单的xml 我已经构建了其中的大部分,但我无法获得当前的产品价格: <?php $path = $_SERVER['DOCUMENT_ROOT']; include_once $path . '/wp-load.php'; header('Content-Type: text/xml; charset=utf-8'); $xml = new SimpleXMLElement('<STORE/
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
include_once $path . '/wp-load.php';
header('Content-Type: text/xml; charset=utf-8');
$xml = new SimpleXMLElement('<STORE/>');
$products = $xml->addChild('PRODUCTS');
// Setup your custom query
$args = array(
'post_type' => 'product',
'posts_per_page' => -1
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() && $count<1) {
$count++;
$loop->the_post();
$wcProduct = new WC_Product( get_the_ID() );
$pr = $wcProduct->get_price_html();
$product = $products->addChild('PRODUCT');
$product->addChild('PRODUCT_URL', get_permalink(get_the_ID()));
$product->addChild('PRODUCT_NAME', get_the_title());
$product->addChild('price', $pr);
}
wp_reset_query();
print($xml->asXML());
?>
它给出了一些相关的东西,有什么解决方法吗?
$pr=$wcProduct->price代码>应该是循环中所需的全部内容,而不是get\u price\u html
调用