希望大家帮帮忙。
我正在一家销售 1 种产品的软件计划的 WooCommerce
商店工作。因此,我停用了购物车页面,并使结账时只能有 1 件商品(旧商品会自动删除)。
我需要的是 echo out
结帐字段前 "cart"
中的产品名称。
例如“Yaaay,您选择了 XXXX 计划!”。
我尝试使用 review-order.php
中的以下代码,但没有成功。
<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key ) . ' '; ?>
有什么想法吗?提前谢谢你。
最佳答案
您可以使用“woocommerce_before_checkout_billing_form” Hook 或“woocommerce_checkout_before_order_review” Hook 为购物车中购买的产品添加标题。
基本上
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.
}
根据您对需要显示标题的位置的要求,使用其中一种代码。
关于php - WooCommerce:在结账时回显产品标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32137645/