如何在woocommerce的结帐页面上的“订单查看"部分中的“自定义"字段中更改产品标题 [英] How to change product title with custom field in the order review section on the checkout page in woocommerce

查看:66
本文介绍了如何在woocommerce的结帐页面上的“订单查看"部分中的“自定义"字段中更改产品标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在woocommerce的结帐页面上的订单查看"部分中的自定义字段中更改产品标题.我有一个高级自定义字段stock_number,我想在结帐页面上的产品评论中使用stock_number字段更改产品标题.

How to change product title with a custom field in the order review section on the checkout page in woocommerce. i have an advanced custom field stock_number i want to change the product title with stock_number field in the product review on the checkout page.

推荐答案

function woocommerce_update_product_title($title, $cart_item){
    if( is_checkout() || is_cart() ) : //Check Checkout or Cart Page
        $stock_number = get_post_meta($cart_item['product_id'], 'stock_number',true);
        return !empty( $stock_number ) ? $stock_number : $title;        
    endif;
    return $title;
}
add_filter('woocommerce_cart_item_name', 'woocommerce_update_product_title', 10, 2); 

请尝试使用此代码,对您有帮助

Please try this code which could help you

这篇关于如何在woocommerce的结帐页面上的“订单查看"部分中的“自定义"字段中更改产品标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆