Guest User

Untitled

a guest
Feb 12th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. /**
  2. * Force all the users autoship orders to be updated if the user
  3. * Changes their address info.
  4. *
  5. * @param bool $update The current update flag. True updates all orders, false doesn't
  6. * @param int $user_id The current users id.
  7. *
  8. * @return bool The filtered update flag.
  9. */
  10. function xx_always_update_my_autoship_scheduled_orders( $update, $user_id ){
  11.  
  12. // Add custom code here
  13. // ex. add a custom "Always apply to my orders" checkbox to user's account
  14. // and retieve the value from the user's metadata
  15. $should_update = get_user_meta($user_id, 'my_custom_user_field_always_update', true );
  16. return empty( $should_update ) ? $udpate : $should_update;
  17.  
  18. }
  19. add_filter('autoship_apply_to_scheduled_orders_by_default', 'xx_always_update_my_autoship_scheduled_orders', 10, 2 );
Add Comment
Please, Sign In to add comment