Skip to main content
WB2
Notifications
Retirer tout

woocommerce-memberships - envoi de plusieurs mail

1 Publications
1 Utilisateurs
0 Reactions
1 Vu
(@lawebfabrik)
Publications: 6
Active Member
Début du sujet
 
[#3972]

Bonjour, J'aurai besoin de l'aide un dev...

J'ai télécharger ce plugin woocommerce memberships. Grace à celui-ci, je peux envoyé un mail à mes abonnés lorsque leur compte arrive à expiration. Seulement je souhaiterai leur en envoyé plusieurs à différents intervalles.

La solution n'est pas proposée par l'éditeur pour le moment. Seule chose qu'il propose : acheter un nouveau plugin (certes très complet) juste pour cela. Impossible pour mes clients.

 

J'ai donc bricolé un peu le plugin en faisant certains tests.

Je suis capable d'envoyer deux mails différents à la même heure et date mais pas à une date différente.

voici le bout de code, qui je pense, pose problème.

 

		// schedule membership expiration hooks, provided there's an end date and it's after the beginning of today's date
		if ( is_numeric( $end_timestamp ) && (int) $end_timestamp > strtotime( 'today', $now ) ) {

			$hook_args = array( 'user_membership_id' => $this->id );

			// Schedule the membership expiration event:
			as_schedule_single_action( $end_timestamp, 'wc_memberships_user_membership_expiry', $hook_args, 'woocommerce-memberships' );

			// Schedule the membership ending soon event:
			$days_before = wc_memberships()->get_user_memberships_instance()->get_ending_soon_days();			
			$time_before = $end_timestamp - ( $days_before * DAY_IN_SECONDS );			
			
			// sanity check: the future can't be in the past :)
			$days_before_expiry = $time_before > current_time( 'timestamp', true ) ?
			$time_before : $end_timestamp - DAY_IN_SECONDS;		
			if ( $end_timestamp > $now ) {

				if ( $days_before_expiry > $now ) {
					// if there's at least one day before the expiry date, use the email setting (days before)
					as_schedule_single_action( $days_before_expiry, 'wc_memberships_user_membership_expiring_soon', $hook_args, 'woocommerce-memberships' );
					as_schedule_single_action( $days_before_expiry, 'wc_memberships_user_membership_expiring_soon_2', $hook_args, 'woocommerce-memberships' );				
			
				} 				
				else {
					// if it's less than one day, schedule as a median time between now and the effective end date (in the course of the last remaining day)
					as_schedule_single_action( max( $now + MINUTE_IN_SECONDS, (int) round( ( $now + $end_timestamp ) / 2 ) ), 'wc_memberships_user_membership_expiring_soon', $hook_args, 'woocommerce-memberships' );
				}
			}
		}

si quelqu'un a une idée, je suis plus que preneur.

D'avance merci !


 
Posté : 08/04/2020 1:10 pm
Share: