【发布时间】:2021-06-23 13:32:14
【问题描述】:
我想使用代码“Prevent access to checkout without shipping method in WooCommerce”和“Avoid proceed-to-checkout-button text refreshing to default text in WooCommerce cart page”更改“继续结帐”按钮的文本而不使用送货方式。
这是我失败的尝试:
function modify_checkout_button_no_shipping() {
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
if( empty( $chosen_shipping_methods ) ) {
remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
add_action( 'woocommerce_proceed_to_checkout', 'modify_checkout_button_no_shipping', 20 );
echo '<a href="'.esc_url(wc_get_checkout_url()).'" class="checkout-button button alt wc-forward">' . __("Alternate checkout text", "woocommerce") . '</a>';
}
}
感谢任何帮助。
【问题讨论】:
标签: php woocommerce cart shipping-method