Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在WooCommerce的多个页面上向产品标题追加文本_Php_Wordpress_Woocommerce_Product_Hook Woocommerce - Fatal编程技术网

Php 在WooCommerce的多个页面上向产品标题追加文本

Php 在WooCommerce的多个页面上向产品标题追加文本,php,wordpress,woocommerce,product,hook-woocommerce,Php,Wordpress,Woocommerce,Product,Hook Woocommerce,我试图在订单meta中向WooCommerce产品标题添加文本-如果产品有特定的标签。我在一家公司工作 “” “” 这就是我所说的: add_filter('woocommerce_get_order_item_total','add_udstilling_在购物车_item_name'下方,'10,3'); 函数add_udstilling_在_cart_item_name($total_rows,$order,$tax_display){; $new_total_rows=[]; for

我试图在订单meta中向WooCommerce产品标题添加文本-如果产品有特定的标签。我在一家公司工作

  • “”

  • “”

这就是我所说的:

add_filter('woocommerce_get_order_item_total','add_udstilling_在购物车_item_name'下方,'10,3');
函数add_udstilling_在_cart_item_name($total_rows,$order,$tax_display){;
$new_total_rows=[];
foreach($total_行作为$key=>$total){
$new_total_行[$key]=$total;
}
}
返回$new\u total\u行;
}
基于您的和这个新问题,我假设您希望看到产品标题调整为“无处不在”

重要的!!你一定要读下面的帖子来 明白这是一个一般性的调整,让你最终 不再需要上一篇文章/问题中的代码

换句话说,您可以开始使用下面的代码在以下位置查看调整

  • 订单接收(谢谢)页面
  • 电子邮件通知
  • 我的账户订单>单订单详细信息
  • 购物车&结帐和后端订单编辑页面
现在,除了商店档案和产品页面,您可以在任何地方更改名称…

函数add\u udstilling\u order\u item\u name($cart){
if(定义了('DOING'uajax'))
返回;
如果(did_action('woocommerce_before_calculate_totals')>=2)
返回;
//循环浏览购物车项目
foreach($cart->get\u cart()作为$cart\u项目){
//获取WC_产品对象的实例
$product=$cart_项目['data'];
//获取产品id
$product_id=$cart_项目['product_id'];
如果(方法_存在($product,'set_name')&&has_term('udstillingmodel','product_tag',$product_id)){
$product->set_name($product->get_name()。(测试)');
}
}
}
添加操作('woocommerce'在计算总计之前,'Addudstilling'订单\项目\名称',10,1);