Woocommerce: Display Product Variation Description on Cart page

前端 未结 3 964
猫巷女王i
猫巷女王i 2021-02-15 10:25

I\'m trying to display my product variation description in my Cart. I have tried inserting this code in the cart.php template:

3条回答
  •  清酒与你
    2021-02-15 11:13

    This will work for WC 3.0

        add_filter( 'woocommerce_cart_item_name', 'cart_variation_description', 20, 3);
    function cart_variation_description( $title, $cart_item, $cart_item_key ) {
        $item = $cart_item['data'];
    
        if(!empty($item) && $item->is_type( 'variation' ) ) {
            return $item->get_name();
        } else
            return $title;
    }
    

提交回复
热议问题