首页 文章

WooCommerce:结账时回收产品名称

提问于
浏览
3

希望你们能帮忙 .

我正在开一家销售1种产品软件计划的商店 . 因此,我已停用购物车页面,并且只能在结帐时有1件商品(旧商品会被自动删除) .

我需要的是,在结帐字段之前 "cart" 中的产品名称也是 echo out .
E.g. "Yaaay, you selected the XXXX-plan!" .

我尝试使用 review-order.php 下面的代码,但没有运气 .

<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key ) . '&nbsp;'; ?>

有任何想法吗?先感谢您 .

1 回答

  • -1

    您可以使用'woocommerce_before_checkout_billing_form'挂钩或'woocommerce_checkout_before_order_review'挂钩来添加购物车中购买产品的 Headers .

    基本上

    add_action('woocommerce_before_checkout_billing_form','wdm_my_custom_title',10,1);
    
    function wdm_my_custom_title($checkout){
     // code to retrieve item title in cart . And echoing it with the custom title which we need.
    }
    

    要么

    add_action('woocommerce_checkout_before_order_review','wdm_my_custom_title',10);
    
    function wdm_my_custom_title(){
     // code to retrieve item title in cart . And echoing it with the custom title which we need.
    }
    

    根据您需要显示 Headers 的位置要求,使用其中一个代码 .

相关问题