尝试通过定制产品循环解析自定义产品模板的属性
我能够获得图像和标题,但不能获得属性。我有这个错误
致命错误:调用未定义的函数get_attribute()
<?php
global $wpdb;
global $product;
$taxrates = $wpdb->get_results($query);
foreach ($taxrates as $taxrate) {
echo get_attribute($taxrate->products_id( 'pa_info' ));
echo get_the_title($taxrate->products_id);
echo get_the_post_thumbnail($taxrate->products_id);
echo $taxrate->rate_2;
echo $taxrate->rate_2;
echo $taxrate->rate_3;
}
?>
答案 0 :(得分:0)
您可以使用get_post_meta来读取属性。
例如,我正在阅读产品的_sale_price
using (var sftp = new SftpClient(sFTPServer, sFTPPassword, sFTPPassword))
{
sftp.Connect();
System.IO.MemoryStream mem = new System.IO.MemoryStream();
System.IO.TextReader textReader = new System.IO.StreamReader(mem);
sftp.DownloadFile("file.txt", mem);
System.IO.TextReader textReader = new System.IO.StreamReader(mem);
string s = textReader.ReadToEnd(); // it is empty
sftp.Disconnect();
}
或WC_Product对象实例
<?php echo get_post_meta($product->ID, "_sale_price", true); ?>
答案 1 :(得分:0)
谢谢,但发现需要通过$ taxrate解析这个
public static void Start()
{
var container = UnityConfig.GetConfiguredContainer();
var resolver = new UnityDependencyResolver(container);
var config = GlobalConfiguration.Configuration;
config.DependencyResolver = resolver;
var providers = config.Services.GetFilterProviders();
var defaultProvider = providers.Single(i => i is ActionDescriptorFilterProvider);
config.Services.Remove(typeof(IFilterProvider), defaultProvider);
config.Services.Add(typeof(IFilterProvider), new UnityActionFilterProvider(container));
}
现在尝试解析外部购物车链接array_shift( wc_get_product_terms( $taxrate->products_id, 'pa_info', array( 'fields' => 'names' ) ) )
但是
致命错误:在a上调用成员函数add_to_cart_url()
中的非对象
任何建议