Woocommerce 将属性添加到特定的 Hook
Woocommerce add Attributes to a specifc Hook
我有那个代码:
add_action('woocommerce_before_single_product', 'wtom_show_attributes_title', 15);
function wtom_show_attributes_title() {
global $product;
$abv = $product->get_attribute ('pa_weingut');
$abb = $product->get_attribute ('pa_weinart');
echo __($abv, $abb, 'woocommerce');
}
它 returns 只有第一个属性 pa_weingut
,我怎样才能使输出显示两个属性?以及如何在输出中添加 css class ?
__() 函数只需要输入参数,但你给它 3。你为什么不调用它两次?
add_action('woocommerce_before_single_product', 'wtom_show_attributes_title', 15);
function wtom_show_attributes_title()
{
global $product;
$abv = $product->get_attribute ('pa_weingut');
$abb = $product->get_attribute ('pa_weinart');
echo "<div class='someclassname'>" . __($abv,'woocommerce') . "</div>";
echo "<div class='someclassname'>" . __($abb,'woocommerce') . "</div>";
}
我有那个代码:
add_action('woocommerce_before_single_product', 'wtom_show_attributes_title', 15);
function wtom_show_attributes_title() {
global $product;
$abv = $product->get_attribute ('pa_weingut');
$abb = $product->get_attribute ('pa_weinart');
echo __($abv, $abb, 'woocommerce');
}
它 returns 只有第一个属性 pa_weingut
,我怎样才能使输出显示两个属性?以及如何在输出中添加 css class ?
__() 函数只需要输入参数,但你给它 3。你为什么不调用它两次?
add_action('woocommerce_before_single_product', 'wtom_show_attributes_title', 15);
function wtom_show_attributes_title()
{
global $product;
$abv = $product->get_attribute ('pa_weingut');
$abb = $product->get_attribute ('pa_weinart');
echo "<div class='someclassname'>" . __($abv,'woocommerce') . "</div>";
echo "<div class='someclassname'>" . __($abb,'woocommerce') . "</div>";
}