Woocommerce Force默认销售仅列出产品名称 . 我需要他们在每个 Headers 旁边的括号中显示产品价格 . 你可以在这个截图中看到它here:
但它应该是:
-
出生泳池租用债券($ 50.00)
-
出生泳池班轮($ 33.00)
我可以使用过滤器,以便Force Sells将价格放在项目旁边吗?除此之外,我如何改变Force Sells代码,以便它也输出价格?
这是Force Sells代码的一部分,该代码输出单个产品页面上“添加到购物车”框下的项目:
/**
* Displays information of what linked products that will get added when current
* product is added to cart.
*/
public function show_force_sell_products() {
global $post;
$product_ids = $this->get_force_sell_ids( $post->ID, array( 'normal', 'synced' ) );
$titles = array();
// Make sure the products still exist and don't display duplicates.
foreach( array_values( array_unique( $product_ids ) ) as $key => $product_id ) {
$product = wc_get_product( $product_id );
if ( $product && $product->exists() && 'trash' !== $product->get_status() ) {
$titles[] = version_compare( WC_VERSION, '3.0', '>=' ) ? $product->get_title() : get_the_title( $product_id );
}
}
if ( ! empty( $titles ) ) {
echo '<div class="clear"></div>';
echo '<div class="wc-force-sells">';
echo '<p>' . __( 'This will also add the following products to your cart:', 'woocommerce-force-sells' ) . '</p>';
echo '<ul>';
foreach ( $titles as $title ) {
echo '<li>' . $title . '</li>';
}
echo '</ul></div>';
}
}
1 回答
您可以尝试以下方法:
代码位于活动子主题(或活动主题)的function.php文件中 . 它应该工作 .