Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Стирать мету с данными bonus+ при изменении платежного телефона #57

Closed
evgrezanov opened this issue Jan 26, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@evgrezanov
Copy link
Owner

evgrezanov commented Jan 26, 2024

// Удаление меты при изменении телефона
add_action( 'woocommerce_customer_save_address', 'remove_user_meta_on_phone_change', 10, 2 );

function remove_user_meta_on_phone_change( $customer_id, $load_address ){
    if ( ! is_user_logged_in() ) return;

    // Получаем старый и новый телефон
    $old_phone = get_user_meta( $customer_id, 'billing_phone', true );
    $new_phone = $load_address['billing_phone'];

    // Если телефон изменился
    if ( $old_phone != $new_phone ) {
        // Удаление меты пользователя
        delete_user_meta( $customer_id, 'custom_meta_key' );
    }
}
@evgrezanov evgrezanov self-assigned this Jan 26, 2024
@evgrezanov evgrezanov added the bug Something isn't working label Jan 26, 2024
@evgrezanov evgrezanov added this to the 2.8 milestone Jan 26, 2024
@evgrezanov evgrezanov removed this from the 2.8 milestone Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

1 participant