WooCommerce:结账时回收产品名称

时间:2022-10-25 11:30:22

Hope you guys can help.

希望你们能帮忙。

I'm working on a WooCommerce shop that sells software-plans for 1 product. Therefor I've deactivated the cart-page and made it possible only to have 1 item in the checkout (old items are automaticly removed).

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

What I need, is too echo out the product name in the "cart" before the checkout fields.
E.g. "Yaaay, you selected the XXXX-plan!".

我需要的是,在结帐字段之前的“购物车”中也会显示产品名称。例如。 “Yaaay,你选择了XXXX计划!”。

I tried to use below code from the review-order.php, but no luck.

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

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

Any ideas? Thank you in advance.

有任何想法吗?先谢谢你。

1 个解决方案

#1


-1  

You can use 'woocommerce_before_checkout_billing_form' hook or 'woocommerce_checkout_before_order_review' hook to add your Title for product purchased in cart.

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

Basically

基本上

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

Or

要么

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

Use one of the codes as per your requirement of location where the Title needs to be displayed.

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

#1


-1  

You can use 'woocommerce_before_checkout_billing_form' hook or 'woocommerce_checkout_before_order_review' hook to add your Title for product purchased in cart.

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

Basically

基本上

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

Or

要么

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

Use one of the codes as per your requirement of location where the Title needs to be displayed.

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