简体   繁体   English

Woocommerce使用单个“添加到购物车”按钮将产品分组

[英]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.

相关问题 Magento分组产品的单独“添加到购物车”按钮 - Individual “Add To Cart” Button for Magento Grouped Products 具有单独“添加到购物车”按钮的分组产品 (Magento) - Grouped Products with Individual “Add To Cart” Button (Magento) 禁用特定 WooCommerce 产品的添加到购物车按钮 - Disabling Add to Cart Button for Specific WooCommerce Products 隐藏WooCommerce变量产品上的“添加到购物车”按钮 - Hiding 'Add to Cart' button on WooCommerce variable products 隐藏大多数产品的添加到购物车按钮-Woocommerce - Hide the add to cart button for most products - Woocommerce 在WooCommerce中为特定产品添加额外添加到购物车按钮 - Add extra add to cart button to specific products in WooCommerce 在 WooCommerce 简单产品的添加到购物车按钮中显示可用性 - Display availability in add to cart button for WooCommerce simple products 禁用 WooCommerce 中一系列产品 ID 的添加到购物车按钮 - Disable add to cart button for an array of products IDs in WooCommerce 在 Woocommerce 中的产品自定义循环上启用 Ajax 添加到购物车按钮 - Enable Ajax add to cart button on products custom loop in Woocommerce WooCommerce:更改多个产品的添加到购物车按钮文本,并重定向到结帐 - WooCommerce: Change add to cart button text for multiple products with a redirection to checkout
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM