覆盖 wc_create_new_customer WooCommerce 函数以允许客人订阅购买

问题描述 投票:0回答:1

在 WooCommerce 中,我需要允许人们在购买订阅时无需注册帐户即可结帐。在 WooCommerce 管理部分的帐户和隐私中,我只有一个选项:启用访客结账(推荐)。

我想覆盖 WooCommerce 插件中的

wc_create_new_customer()
函数代码,位于 includes/wc-user-functions.php PHP 文件,使用以下内容:

function wc_create_new_customer( $email, $username = '', $password = '', $args = array() ) {
    if ( empty( $email ) || ! is_email( $email ) ) {
        return new WP_Error( 'registration-error-invalid-email', __( 'Please provide a valid email address.', 'woocommerce' ) );
    }

    if ( email_exists( $email ) ) {
        return new WP_Error( 'registration-error-email-exists', apply_filters( 'woocommerce_registration_error_email_exists', __( 'An account is already registered with your email address. <a href="#" class="showlogin">Please log in.</a>', 'woocommerce' ), $email ) );
    }

    return false;
}

但 WooCommerce 似乎不允许覆盖

wc_create_new_customer()
函数。

是否可以覆盖结账时使用的功能?

php function woocommerce checkout overwrite
1个回答
0
投票

唯一的办法就是直接修改wc_create_new_customer函数,阻止wc的更新,避免覆盖文件

© www.soinside.com 2019 - 2024. All rights reserved.