[英]Woocommerce Grouped Products with Individual “Add To Cart” Button
I am trying to achieve the following: 我正在努力实现以下目标:
On the grouped product detail page a Add to Cart button for each Individual item, also for each item the Individual price must be listed. 在分组的产品详细信息页面上,每个单独商品的“添加到购物车”按钮,也必须为每个商品列出单独的价格。 I have seen the following can be done but i need to get it working in a grouped product;
我已经看到可以完成以下操作,但是我需要使其在分组产品中工作;
Adding Woocommerce Add to Cart Button to related products and product listing 将Woocommerce添加到购物车Button到相关产品和产品列表
Any suggestions? 有什么建议么? Many Thanks!
非常感谢!
Heres how to make a hook work with grouped products in woocommerce. 以下是在woocommerce中如何与分组产品配合使用的方法。 Just replace the add_action() below with any add_action or remove_action you want to use.
只需将下面的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 );
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.