updated offers expiration hanling with separate checkbox for each 3 offers

This commit is contained in:
asus
2024-04-16 16:43:11 +02:00
parent d3e0fbb99e
commit 62dcaa7672
8 changed files with 72 additions and 145 deletions

View File

@@ -15,6 +15,8 @@ if (!defined('ABSPATH')) {
function handle_partner_offers_expire_CIPF($page_id) {
Plgntls::debug_infos();
$post = get_post($page_id);
$i = 1;
while ($i <= 3) {
$offer_duration = get_field_init_CIPF('duree_offre_'.$i, $page_id);
@@ -27,8 +29,12 @@ function handle_partner_offers_expire_CIPF($page_id) {
++$i;
continue;
}
handle_offer_is_expired_CIPF($i, $page_id);
$offer_title = get_field_init_CIPF('offre_'.$i.'_titre', $page_id);
error_log("- post: ".$post->post_title." - titre offre: ".$offer_title);
handle_offer_will_expire_CIPF($i, $page_id);
handle_offer_is_expired_CIPF($i, $page_id);
++$i;
}
}
@@ -48,9 +54,9 @@ function handle_offer_will_expire_CIPF($i, $page_id) {
$post = get_post($page_id);
$user_id = $post->post_author;
handle_send_reminders_CIPF($page_id, $user_id, $date_limit, 'offer_expiration', 'offer_will_expire');
handle_send_reminders_CIPF($page_id, $user_id, $date_limit, 'offer_expiration_'.$i, 'offer_will_expire');
}
function handle_offer_is_expired_CIPF($i, $page_id) {
@@ -61,7 +67,9 @@ function handle_offer_is_expired_CIPF($i, $page_id) {
}
update_field('afficher_offre_'.$i, 'Masquer', $page_id);
set_email_reminder_choice_CIPF('offer_expired', $acf_id);
$post = get_post($page_id);
$user_id = $post->post_author;
send_emails_CIPF('offer_expired', $user_id);
}