2016-05-09 43 views
1

我努力實現以下目標:與個人Woocommerce分組的產品「加入購物車」按鈕

在分組商品詳細頁一加入購物車按鈕,每個單項的,也是每個項目的個別價格必須被列出。我已經看到了以下可以完成,但我需要得到它在一個分組產品工作;

Adding Woocommerce Add to Cart Button to related products and product listing

有什麼建議?非常感謝!

+0

如果您向我展示了適用於所有產品的代碼,我將向您展示如何使其僅適用於分組產品。 – Scott

+0

這是完美的!非常感謝!! – Phillip

回答

0

如何在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); 

     } 
    } 
} 
+0

非常感謝隊友!完美的幫助! – Phillip

+0

你還可以幫助我如何爲每個產品添加圖像嗎?我現在有分組的產品圖像,但不是鬆散圖像專業版產品。非常感謝先進的 – Phillip

+0

我發現以下,但我不知道在哪裏添加代碼... http://stackoverflow.com/questions/17524550/woocommerce-grouped-product-images – Phillip

相關問題