From 9ee35b23bca7486bf578f117fc6b02b09e3de50a Mon Sep 17 00:00:00 2001 From: asus Date: Sun, 10 Mar 2024 14:51:47 +0100 Subject: [PATCH] - renew state : removed - payment state : in acf --- .../php/paypal/update_user_payment.php | 62 +------------------ plugins/cipf_plugin/php/prof_check_page.php | 9 +-- plugins/cipf_plugin/php/renew_card.php | 5 +- plugins/cipf_plugin/utils/plgntls_class.php | 2 +- private | 2 +- 5 files changed, 8 insertions(+), 72 deletions(-) diff --git a/plugins/cipf_plugin/php/paypal/update_user_payment.php b/plugins/cipf_plugin/php/paypal/update_user_payment.php index 4592da1..7cb37eb 100644 --- a/plugins/cipf_plugin/php/paypal/update_user_payment.php +++ b/plugins/cipf_plugin/php/paypal/update_user_payment.php @@ -36,7 +36,6 @@ if (!defined('ABSPATH')) { */ function update_user_pre_order_CIPF($message) { PLGNTLS_class::debug_infos(); - //$meta_payement_status = PLGNTLS_class::META_PAYEMENT_STATUS; $acf_payment_status = PLGNTLS_class::ACF_CARD_PAYMENT_STATE; $meta_order_id = PLGNTLS_class::META_ORDER_ID; @@ -60,8 +59,6 @@ function update_user_pre_order_CIPF($message) { * - 'failure' -> at capture failure (on author page, it means failure, then make it empty) * - 'nothing' -> output nothing on author page * - delete_user_meta($user_id, $meta_payement_status); - add_user_meta($user_id, $meta_payement_status, 'started'); */ update_field($acf_payment_status['_name'], $acf_payment_status['started'], $acf_id); } @@ -134,10 +131,8 @@ function failure_payment_for_user_CIPF($user_id, $order_id, $status) { $acf_card_state = PLGNTLS_class::ACF_CARD_STATE; $acf_card_expiration = PLGNTLS_class::ACF_CARD_EXPIRATION; - $acf_prof_can_renew = PLGNTLS_class::ACF_PROF_CAN_RENEW; $card_duration = PLGNTLS_class::CARD_VALIDITY_TIME; $prof_is_activ = PLGNTLS_class::ACF_PROF_IS_ACTIV; - //$meta_payement_status = PLGNTLS_class::META_PAYEMENT_STATUS; $acf_payment_status = PLGNTLS_class::ACF_CARD_PAYMENT_STATE; $meta_order_id = PLGNTLS_class::META_ORDER_ID; @@ -156,71 +151,18 @@ function failure_payment_for_user_CIPF($user_id, $order_id, $status) { * - 'failure' -> at capture failure (on author page, it means failure, then mark it 'nothing') * - 'nothing' -> output nothing on author page * - update_user_meta($user_id, $meta_payement_status, 'failure'); */ update_field($acf_payment_status['_name'], $acf_payment_status['failure'], $acf_id); - /* - * acf uses 'Y-m-d H:i:s' format : https://www.advancedcustomfields.com/resources/date-time-picker/ - * - */ - $acf_date_format = 'Y-m-d H:i:s'; - $acf_id = 'user_'.$user_id; - - $date_now = date_create('today'); - - /* - * update purchase date to now - * - update_field(CARD_DATE_PURCHASE, $date_now, $acf_id); - */ - - /* - * get current date limit - * if no date, use now - * if paste date, use now - * - */ - $current_date_limit_object = get_field_object($acf_card_expiration['_name'], $acf_id); - - if ($current_date_limit_object === false) { - $current_date_limit = $date_now; - } - else if (empty($current_date_limit_object['value'])) { - $current_date_limit = $date_now; - } - else - { - $current_date_limit_string = $current_date_limit_object['value']; - $current_format_field = $current_date_limit_object['return_format']; - // compare 2 dates : https://stackoverflow.com/q/8722806/9497573 - // also I dont use strtotime to compare 2 ints, - // because i don't know if it will fail one day (2000 bug alike) - $current_date_limit = date_create_from_format($current_format_field, $current_date_limit_string); - $date_diff = date_diff($date_now, $current_date_limit); - $date_is_in_past = $date_diff->format('%R%a') < 0; - - if ($date_is_in_past) - $current_date_limit = $date_now; - } - - /* - * update date limit validity to add 1 year - * - */ - $date_plus_one_year = $current_date_limit->add(date_interval_create_from_date_string('+'.$card_duration)); - update_field($acf_card_expiration['_name'], $date_plus_one_year->format($acf_date_format), $acf_id); /* * change user profil : * - to active * - card state is renewal - * - cannot renew * */ update_field($prof_is_activ['_name'], $prof_is_activ['activ'], $acf_id); update_field($acf_card_state['_name'], $acf_card_state['renew'], $acf_id); - //update_field($acf_prof_can_renew['_name'], $acf_prof_can_renew['cannot'] , $acf_id); } @@ -232,10 +174,9 @@ function validate_payment_for_user_CIPF($user_id, $order_id) { PLGNTLS_class::debug_infos(); $acf_card_state = PLGNTLS_class::ACF_CARD_STATE; $acf_card_expiration = PLGNTLS_class::ACF_CARD_EXPIRATION; - $acf_prof_can_renew = PLGNTLS_class::ACF_PROF_CAN_RENEW; +// $acf_prof_can_renew = PLGNTLS_class::ACF_PROF_CAN_RENEW; $card_duration = PLGNTLS_class::CARD_VALIDITY_TIME; $prof_is_activ = PLGNTLS_class::ACF_PROF_IS_ACTIV; - //$meta_payement_status = PLGNTLS_class::META_PAYEMENT_STATUS; $acf_payment_status = PLGNTLS_class::ACF_CARD_PAYMENT_STATE; $meta_order_id = PLGNTLS_class::META_ORDER_ID; @@ -250,7 +191,6 @@ function validate_payment_for_user_CIPF($user_id, $order_id) { /* * change payement status to success * - update_user_meta($user_id, $meta_payement_status, 'success'); */ update_field($acf_payment_status['_name'], $acf_payment_status['success'], $acf_id); diff --git a/plugins/cipf_plugin/php/prof_check_page.php b/plugins/cipf_plugin/php/prof_check_page.php index 9fd1a63..c1f6721 100644 --- a/plugins/cipf_plugin/php/prof_check_page.php +++ b/plugins/cipf_plugin/php/prof_check_page.php @@ -72,7 +72,6 @@ function handle_prof_is_activ_CIPF($author_id) { function show_prof_paiement_messages_CIPF($user_id) { PLGNTLS_class::debug_infos(); $acf_prof_is_activ = PLGNTLS_class::ACF_PROF_IS_ACTIV; - //$meta_payement_status = PLGNTLS_class::META_PAYEMENT_STATUS; $acf_payment_status = PLGNTLS_class::ACF_CARD_PAYMENT_STATE; $acf_id = 'user_' . $user_id; @@ -89,22 +88,18 @@ function show_prof_paiement_messages_CIPF($user_id) { $cipf_prof_payement = new PLGNTLS_class(); - //$payement_status = get_user_meta($user_id, $meta_payement_status, true); $payement_status = get_field($acf_payment_status['_name'], $acf_id); - //if ($payement_status === 'success') { if ($payement_status === $acf_payment_status['success']) { $cipf_prof_payement->add_to_front(array( - array( 'css' => '#cipf_prof_paiement_reussi {display: block;}' ) + array( 'css' => '.cipf_prof_paiement_message#cipf_prof_paiement_reussi {display: block;}' ) )); } - //else if ($payement_status === 'started') { else if ($payement_status === $acf_payment_status['failure']) { $cipf_prof_payement->add_to_front(array( - array( 'css' => '#cipf_prof_paiement_echoue {display: block;}' ) + array( 'css' => '.cipf_prof_paiement_message#cipf_prof_paiement_echoue {display: block;}' ) )); } - //update_user_meta($user_id, $meta_payement_status, ''); update_field($acf_payment_status['_name'], $acf_payment_status['nothing'], $acf_id); } diff --git a/plugins/cipf_plugin/php/renew_card.php b/plugins/cipf_plugin/php/renew_card.php index c965094..9efbf94 100644 --- a/plugins/cipf_plugin/php/renew_card.php +++ b/plugins/cipf_plugin/php/renew_card.php @@ -52,7 +52,7 @@ function renew_page_restrictions_CIPF(){ PLGNTLS_class::debug_infos(); $slug_renew_card = PLGNTLS_class::SLUG_RENEW_CARD; $slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION; - $acf_prof_can_renew = PLGNTLS_class::ACF_PROF_CAN_RENEW; +// $acf_prof_can_renew = PLGNTLS_class::ACF_PROF_CAN_RENEW; if (!is_page($slug_renew_card)) return; @@ -78,8 +78,8 @@ function renew_page_restrictions_CIPF(){ /* * if prof, check card state + * if cannot renew, redirect * - */ if (current_user_can('professeur__professeure')) { $can_renew = get_field($acf_prof_can_renew['_name'], $acf_id); if ($can_renew === false) { @@ -88,6 +88,7 @@ function renew_page_restrictions_CIPF(){ exit; } } + */ /* * if prof can renew its card, reset some form fields before diff --git a/plugins/cipf_plugin/utils/plgntls_class.php b/plugins/cipf_plugin/utils/plgntls_class.php index 8c9428c..07f632b 100644 --- a/plugins/cipf_plugin/utils/plgntls_class.php +++ b/plugins/cipf_plugin/utils/plgntls_class.php @@ -67,7 +67,7 @@ class PLGNTLS_class const ACF_CARD_PRICE_DELIVERY = ['_name'=>'livraison', 'pdf'=>'PDF', 'post'=>'Fabrication']; // radio button const ACF_PROF_IS_ACTIV = ['_name'=>'compte-actif', 'activ'=>'Actif', 'inactiv'=>'Inactif']; // radio button const ACF_PROF_CGV = ['_name'=>'cgv', 'cgv'=>'cgv']; // checkbox - const ACF_PROF_CAN_RENEW = ['_name'=>'renouvellement_possible', 'can'=>true, 'cannot'=>false]; // true/false +// const ACF_PROF_CAN_RENEW = ['_name'=>'renouvellement_possible', 'can'=>true, 'cannot'=>false]; // true/false const ACF_CARD_PRICE_TOTAL = ['_name'=>'somme_a_regler']; // number const ACF_CARD_CARD_NUMBER = ['_name'=>'numero_de_la_carte']; // number const ACF_CARD_EXPIRATION = ['_name'=>'fin_de_validite']; // date picker diff --git a/private b/private index f90162b..516706c 160000 --- a/private +++ b/private @@ -1 +1 @@ -Subproject commit f90162bddccbd22426755f11eace37504f779f87 +Subproject commit 516706ca48caeab03045fe8df331a147dc22f2bb