Woocommerce使用单个“添加到购物车"按钮将产品分组 [英] Woocommerce Grouped Products with Individual “Add To Cart” Button

查看:107
本文介绍了Woocommerce使用单个“添加到购物车"按钮将产品分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力实现以下目标:

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;

添加Woocommerce加入购物车相关产品和产品列表的按钮

有什么建议吗?非常感谢!

Any suggestions? Many Thanks!

推荐答案

此处介绍如何在woocommerce中使用分组产品的挂钩.只需将下面的add_action()替换为您要使用的任何add_action或remove_action.

Heres how to make a hook work with grouped products in woocommerce. Just replace the add_action() below with any add_action or remove_action you want to use.

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 );

        }
    }
}

这篇关于Woocommerce使用单个“添加到购物车"按钮将产品分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆