- added isset function in acf field centralized handling
- schedule event for order id works
This commit is contained in:
@@ -60,7 +60,14 @@ function schedule_delete_orderid_CIPF($user_id, $order_id) {
|
|||||||
}
|
}
|
||||||
function delete_order_id_later_CIPF($user_id, $order_id) {
|
function delete_order_id_later_CIPF($user_id, $order_id) {
|
||||||
Plgntls::debug_infos();
|
Plgntls::debug_infos();
|
||||||
delete_user_meta($user_id, 'cipf_order_id', $order_id);
|
|
||||||
|
if (!isset_acf_order_id_CIPF($user_id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!is_acf_order_id_CIPF($order_id, $user_id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
reset_acf_order_id_CIPF($user_id);
|
||||||
}
|
}
|
||||||
add_action('orderid_deletion_event_CIPF', 'delete_order_id_later_CIPF', 10, 2);
|
add_action('orderid_deletion_event_CIPF', 'delete_order_id_later_CIPF', 10, 2);
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ if (!defined('ABSPATH')) {
|
|||||||
*
|
*
|
||||||
* [/] cgv
|
* [/] cgv
|
||||||
*
|
*
|
||||||
* [/] order_id
|
* [/] order id ('order_id')
|
||||||
|
*
|
||||||
|
* [/] card expiration date ('fin_de_validite')
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -52,7 +54,6 @@ if (!defined('ABSPATH')) {
|
|||||||
function get_field_init_CIPF($acf_field_name, $acf_id) {
|
function get_field_init_CIPF($acf_field_name, $acf_id) {
|
||||||
Plgntls::debug_infos();
|
Plgntls::debug_infos();
|
||||||
$acf_state = get_field($acf_field_name, $acf_id);
|
$acf_state = get_field($acf_field_name, $acf_id);
|
||||||
error_log("acf_state: " . json_encode($acf_state));
|
|
||||||
if ($acf_state !== null) {
|
if ($acf_state !== null) {
|
||||||
return $acf_state;
|
return $acf_state;
|
||||||
}
|
}
|
||||||
@@ -104,7 +105,14 @@ function is_acf_field_CIPF($acf_field, $acf_value, $acf_id) {
|
|||||||
*/
|
*/
|
||||||
$acf_state = get_field_init_CIPF($acf_field['_name'], $acf_id);;
|
$acf_state = get_field_init_CIPF($acf_field['_name'], $acf_id);;
|
||||||
|
|
||||||
if ($acf_state === $acf_field[$acf_value]) {
|
if (is_predefined_acf_state($acf_field, $acf_value)) {
|
||||||
|
$value = $acf_field[$acf_value];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$value = $acf_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($acf_state === $value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -168,6 +176,25 @@ function get_acf_field_CIPF($acf_field, $acf_id) {
|
|||||||
Plgntls::debug_infos();
|
Plgntls::debug_infos();
|
||||||
return get_field_init_CIPF($acf_field['_name'], $acf_id);
|
return get_field_init_CIPF($acf_field['_name'], $acf_id);
|
||||||
}
|
}
|
||||||
|
function isset_acf_field_CIPF($acf_field, $acf_id) {
|
||||||
|
Plgntls::debug_infos();
|
||||||
|
|
||||||
|
$value = get_field($acf_field['_name'], $acf_id);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* before first use : returns null
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if (is_null($value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (empty($value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -509,6 +536,26 @@ function reset_acf_cgv_CIPF($user_id = null) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* fin_de_validite
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function isset_acf_card_expiration_CIPF($user_id = null) {
|
||||||
|
Plgntls::debug_infos();
|
||||||
|
$acf_card_expiration = Cipf::ACF_CARD_EXPIRATION;
|
||||||
|
|
||||||
|
if (is_null($user_id)) {
|
||||||
|
$user_id = get_current_user_id();
|
||||||
|
}
|
||||||
|
$acf_id = 'user_'.$user_id;
|
||||||
|
return isset_acf_field_CIPF($acf_card_expiration, $acf_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* order_id
|
* order_id
|
||||||
*
|
*
|
||||||
@@ -543,6 +590,26 @@ function set_acf_order_id_CIPF($order_id, $user_id = null) {
|
|||||||
$acf_id = 'user_'.$user_id;
|
$acf_id = 'user_'.$user_id;
|
||||||
set_acf_field_CIPF($acf_order_id, $order_id, $acf_id);
|
set_acf_field_CIPF($acf_order_id, $order_id, $acf_id);
|
||||||
}
|
}
|
||||||
|
function isset_acf_order_id_CIPF($user_id = null) {
|
||||||
|
Plgntls::debug_infos();
|
||||||
|
$acf_order_id = Cipf::ACF_CARD_ORDER_ID;
|
||||||
|
|
||||||
|
if (is_null($user_id)) {
|
||||||
|
$user_id = get_current_user_id();
|
||||||
|
}
|
||||||
|
$acf_id = 'user_'.$user_id;
|
||||||
|
return isset_acf_field_CIPF($acf_order_id, $acf_id);
|
||||||
|
}
|
||||||
|
function is_acf_order_id_CIPF($order_id, $user_id = null) {
|
||||||
|
Plgntls::debug_infos();
|
||||||
|
$acf_order_id = Cipf::ACF_CARD_ORDER_ID;
|
||||||
|
|
||||||
|
if (is_null($user_id)) {
|
||||||
|
$user_id = get_current_user_id();
|
||||||
|
}
|
||||||
|
$acf_id = 'user_'.$user_id;
|
||||||
|
return is_acf_field_CIPF($acf_order_id, $order_id, $acf_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -560,15 +627,15 @@ function is_transfert_success_CIPF($user_id = null) {
|
|||||||
$user_id = get_current_user_id();
|
$user_id = get_current_user_id();
|
||||||
}
|
}
|
||||||
$acf_id = 'user_'.$user_id;
|
$acf_id = 'user_'.$user_id;
|
||||||
// we dont use the utility function 'get_acf_field_CIPF()' because we want to know if it was never init. Do we ?
|
|
||||||
$transfert_state = get_field($acf_transfert_state['_name'], $acf_id);
|
|
||||||
|
|
||||||
|
// we dont use the utility function 'get_acf_field_CIPF()' because we want to know if it was never init. Do we ?
|
||||||
|
//$transfert_state = get_field($acf_transfert_state['_name'], $acf_id);
|
||||||
|
return isset_acf_field_CIPF($acf_transfert_state, $acf_id);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* before first use : returns null
|
* before first use : returns null
|
||||||
* if checked : returns value
|
* if checked : returns value
|
||||||
* if unchecked : returns empty
|
* if unchecked : returns empty
|
||||||
*/
|
|
||||||
if (is_null($transfert_state)) {
|
if (is_null($transfert_state)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -578,6 +645,7 @@ function is_transfert_success_CIPF($user_id = null) {
|
|||||||
else {
|
else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
function reset_acf_transfert_CIPF($user_id = null) {
|
function reset_acf_transfert_CIPF($user_id = null) {
|
||||||
Plgntls::debug_infos();
|
Plgntls::debug_infos();
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ function failure_payment_for_user_CIPF($user_id, $order_id, $status) {
|
|||||||
|
|
||||||
$acf_id = 'user_'.$user_id;
|
$acf_id = 'user_'.$user_id;
|
||||||
|
|
||||||
// schedule_delete_orderid_CIPF($user_id, $order_id)
|
schedule_delete_orderid_CIPF($order_id, $user_id);
|
||||||
set_payment_failure_CIPF($user_id);
|
set_payment_failure_CIPF($user_id);
|
||||||
set_account_to_pay_CIPF($user_id);
|
set_account_to_pay_CIPF($user_id);
|
||||||
send_emails_CIPF('payment_echec', $user_id);
|
send_emails_CIPF('payment_echec', $user_id);
|
||||||
@@ -140,10 +140,7 @@ function failure_payment_for_user_CIPF($user_id, $order_id, $status) {
|
|||||||
function success_payment_for_user_CIPF($user_id, $order_id) {
|
function success_payment_for_user_CIPF($user_id, $order_id) {
|
||||||
Plgntls::debug_infos();
|
Plgntls::debug_infos();
|
||||||
|
|
||||||
$acf_id = 'user_'.$user_id;
|
schedule_delete_orderid_CIPF($order_id, $user_id);
|
||||||
|
|
||||||
|
|
||||||
// schedule_delete_orderid_CIPF($user_id, $order_id)
|
|
||||||
update_card_expiration_CIPF($user_id);
|
update_card_expiration_CIPF($user_id);
|
||||||
|
|
||||||
if (is_card_new_CIPF()) {
|
if (is_card_new_CIPF()) {
|
||||||
|
|||||||
@@ -148,16 +148,17 @@ function card_date_exists_CIPF($user_id = null) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$date_now = date_create('today');
|
$date_now = date_create('today');
|
||||||
// we dont use utility fonction 'get_acf_field_CIPF' because we want to know if it was not init. Do we ?
|
// // we dont use utility fonction 'get_acf_field_CIPF' because we want to know if it was not init. Do we ?
|
||||||
$current_date = get_field($acf_card_expiration['_name'], $acf_id);
|
// $current_date = get_field($acf_card_expiration['_name'], $acf_id);
|
||||||
|
//
|
||||||
if (empty($current_date)) {
|
// if (empty($current_date)) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
if (is_null($current_date)) {
|
// if (is_null($current_date)) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
|
return isset_acf_card_expiration_CIPF($user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user