避免将继续结帐按钮的文本刷新为WooCommerce购物车页面中的默认文本 [英] Avoid proceed-to-checkout-button text refreshing to default text in WooCommerce cart page

查看:37
本文介绍了避免将继续结帐按钮的文本刷新为WooCommerce购物车页面中的默认文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在WooCommerce中,在店面子主题中,我在 proceed-to-checkout-button.php 中编辑了代码,以将措辞从继续进行结帐"更改为进行结帐":

In WooCommerce, in my Storefront child theme, I edited the code in proceed-to-checkout-button.php to change the wording from "Proceed to checkout" to "Checkout":

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
}
?>

<a href="<?php echo esc_url( wc_get_checkout_url() ); ?>" class="checkout-button button wc-forward">
    <?php esc_html_e( 'Checkout', 'woocommerce' ); ?>
</a> 

但是,当用户在购物车页面中更改产品数量时,按钮文本将恢复为默认的继续结帐".

But when the user changes product quantity in the cart page, then the button text goes back to default "Proceed to checkout".

是否有过滤器或在何处编辑此更新的文本?

Is there a filter or where to edit this updated text?

编辑-已解决问题

该问题与 WooCommerce更好的可用性pro 中的特定购物车选项有关.需要禁用(未选中) 选项在自动更新购物车时显示文本" 的插件.

The issue was related to a specific cart option in WooCommerce Better Usability pro plugin where the option "Display text while updating cart automatically" requires to be disabled (unselected).

推荐答案

而不是覆盖 proceded-to-checkout-button.php 文件,而应使用以下内容:

Instead of overriding proceed-to-checkout-button.php file, should use the following instead:

remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
add_action( 'woocommerce_proceed_to_checkout', 'custom_button_proceed_to_checkout', 20 );
function custom_button_proceed_to_checkout() {
    echo '<a href="'.esc_url(wc_get_checkout_url()).'" class="checkout-button button alt wc-forward">' .
    __("Checkout", "woocommerce") . '</a>';
}

代码进入您的活动子主题(或活动主题)的functions.php文件中.经过测试,可以在Storefront主题下使用最新的WooCommerce版本.

Code goes in functions.php file of your active child theme (or active theme). Tested and works on last WooCommerce version under Storefront theme.

现在,由于您已经在模板中进行了许多自定义,或者正在使用购物车页面中的某些插件进行自定义,因此由于这些自定义,问题仍然存在.

Now as you have done a lot of customizations in your templates or may be you are using some plugin in cart page for customization, the problem can remains due to those customizations.

这篇关于避免将继续结帐按钮的文本刷新为WooCommerce购物车页面中的默认文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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