Reputation: 31
I'm using Woocommerce Subscriptions and currently the below action hook fires when you update your address on your Account Page > Edit Shipping (my-account/edit-address/shipping/) - HOWEVER it does not fire when you update your address on the Account > View subscription page > Edit Shipping (/my-account/edit-address/shipping/?subscription=62400).
function kidstir_email_customer_address( $user_id ) {
// do stuff
}
add_action( 'woocommerce_customer_save_address','kidstir_email_customer_address', 20 );
I've been looking for hours, and can't figure out why it's not firing, or how to get a notification that a subscription address has changed. Has anyone else had this issue?
Upvotes: 2
Views: 1879
Reputation: 5107
We couldn't find a good solution that doesn't involve editing core/plugins, so we did this instead:
// make the "update address on all active subscriptions" box checked by default
add_filter( 'wcs_update_all_subscriptions_addresses_checked', '__return_true' );
#update_all_subscriptions_addresses_field {
display: none;
}
function customslug_subscription_actions( $actions, $subscription, $user_id ) {
$actions['change_address']['url'] = '/my-account/edit-address/shipping/';
return $actions;
}
add_filter( 'wcs_view_subscription_actions', 'customslug_subscription_actions', 999, 3 );
It's not a great solution, but it's better than leaving things broken and confusing for users...
If having access to the woocommerce_customer_save_address
hook is essential for your use case, but making individual subscription addresses editable is not, this might work for you too.
Upvotes: 0
Reputation: 31
The version of WooCommerce Subscriptions (2.0.9) does not call the woocommerce_customer_save_address hook in file class-wc-subscriptions-addresses.php
To solve my problem I edited this file (I know editing core is not advisable) to call the hook (doaction etc) on line 137.
Upvotes: 1
Reputation: 5070
According to official documentation of the WooCommerce Subscriptions plugin, there is a updated_users_subscriptions
hook.
Upvotes: 0