【问题标题】:WooCommerce: Echo product title in checkoutWooCommerce:结帐时回显产品标题
【发布时间】:2015-11-15 05:46:37
【问题描述】:

希望大家帮忙。

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

我需要的也是结帐字段前"cart" 中的echo out 产品名称。
例如“Yaaay,你选择了 XXXX 计划!”。

我尝试使用review-order.php 中的以下代码,但没有成功。

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

有什么想法吗?提前谢谢你。

【问题讨论】:

    标签: php wordpress woocommerce checkout


    【解决方案1】:

    您可以使用“woocommerce_before_checkout_billing_form”挂钩或“woocommerce_checkout_before_order_review”挂钩为购物车中购买的产品添加标题。

    基本上

    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.
    }
    

    根据需要显示标题的位置的要求,使用其中一种代码。

    【讨论】:

    • 感谢您的回复。不幸的是,把它放在盒子“里面”而不是上面:link
    猜你喜欢
    • 1970-01-01
    • 2021-05-18
    • 1970-01-01
    • 2019-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多