在Woocommerce Checkout页面中添加信息丰富的自定义消息 [英] Add an informative custom message in Woocommerce Checkout page

查看:60
本文介绍了在Woocommerce Checkout页面中添加信息丰富的自定义消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于WP/Woocommerce的网站,我想通知我的客户,每当他们在我的商店中购买商品时,其订单的3%就移交给了慈善协会.

I have a WP/Woocommerce based website, and I would like to inform my clients that, whenever they buy something in my shop, the 3% of their order is devolved for charity associations.

我想显示基于总计计算出的确切金额,例如:总计:150€

I would like to display the exact amount calculated on the total, for example: Total: 150 €

5欧元将被下放,等等.

5 € will be devolved etc.

我该如何管理?

推荐答案

您可以通过以下方式在结帐页面上将其显示为Woocommerce的成功"通知:

You could display it as a Woocommerce "success" notice in checkout page, this way:

add_action( 'woocommerce_before_checkout_form', 'print_donation_notice', 10 );
function print_donation_notice() {
    wc_print_notice( sprintf(
        __("%s 3%% of this order will be devolved for charity associations, so an amount of %s.", "woocommerce"),
        '<strong>' . __("Information:", "woocommerce") . '</strong>',
        strip_tags( wc_price( WC()->cart->get_subtotal() * 0.03 ) )
    ), 'success' );
}

代码进入您的活动子主题(或活动主题)的function.php文件中.经过测试,可以正常工作.

Code goes in function.php file of your active child theme (or active theme). Tested and works.

这篇关于在Woocommerce Checkout页面中添加信息丰富的自定义消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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