Woocommerce 分组产品带有单独的“添加到购物车”按钮
Woocommerce Grouped Products with Individual “Add To Cart” Button
我正在努力实现以下目标:
在分组产品详细信息页面上,每个单独项目的添加到购物车按钮,也必须列出每个项目的单独价格。我已经看到可以完成以下操作,但我需要让它在分组产品中工作;
Adding Woocommerce Add to Cart Button to related products and product listing
有什么建议吗?非常感谢!
以下是如何在 woocommerce 中使用分组产品挂钩。只需将下面的 add_action() 替换为您要使用的任何 add_action 或 remove_action。
add_action('woocommerce_after_shop_loop_item', 'woo_custom_hook_function');
function woo_cusom_hook_function() {
global $post;
if (function_exists( 'get_product' )) {
$product = get_product( $post->ID );
if ($product->is_type( 'grouped' )) {
// anything you hook into above will be run here for grouped products only.
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
}
}
我正在努力实现以下目标:
在分组产品详细信息页面上,每个单独项目的添加到购物车按钮,也必须列出每个项目的单独价格。我已经看到可以完成以下操作,但我需要让它在分组产品中工作;
Adding Woocommerce Add to Cart Button to related products and product listing
有什么建议吗?非常感谢!
以下是如何在 woocommerce 中使用分组产品挂钩。只需将下面的 add_action() 替换为您要使用的任何 add_action 或 remove_action。
add_action('woocommerce_after_shop_loop_item', 'woo_custom_hook_function');
function woo_cusom_hook_function() {
global $post;
if (function_exists( 'get_product' )) {
$product = get_product( $post->ID );
if ($product->is_type( 'grouped' )) {
// anything you hook into above will be run here for grouped products only.
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
}
}