在woocommerce购物车页面中更改数量标签

Pus*_*Pus 2 wordpress woocommerce

如何更改woocommerce购物车页面中表格标题中显示的数量标签?我需要将数量的标题标签更改为其他内容.

小智 8

您需要编辑购物车页面的模板文件.

您的主题是否已在每个模板中都有/ woocommerce /文件夹?如果没有,你应该将/ cart /文件夹从/ wp-content/plugins/woocommerce/templates /复制到/ your-theme/woocommerce /然后编辑/cart/cart.php并搜索"Quantity".

您还可以在functions.php文件中使用此技巧来替换您网站上显示"数量"的所有内容:

add_filter('gettext', 'translate_reply');
add_filter('ngettext', 'translate_reply');

function translate_reply($translated) {
$translated = str_ireplace('Quantity', 'New Label', $translated);
return $translated;
}
Run Code Online (Sandbox Code Playgroud)

只需将"新标签"更改为您想要的任何名称即可.