- fixed error in acf fields handling
- added history handler
This commit is contained in:
@@ -82,6 +82,7 @@ class Cipf {
|
||||
const ACF_TRANSFERT_STATE = ['_name'=>'etat_virement', 'success'=>'virement validé'];
|
||||
const ACF_PAGE_STATE = ['_name'=>'etat_page_partenaire', 'publish'=>'Publiee', 'draft'=>'Brouillon'];
|
||||
const ACF_CARD_ORDER_ID = ['_name'=>'order_id'];
|
||||
const ACF_HISTORY = ['_name'=>'history'];
|
||||
|
||||
// META
|
||||
const META_PAYEMENT_STATUS = 'cipf_payement_status';
|
||||
|
||||
@@ -52,6 +52,7 @@ if (!defined('ABSPATH')) {
|
||||
function get_field_init_CIPF($acf_field_name, $acf_id) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_state = get_field($acf_field_name, $acf_id);
|
||||
error_log("acf_state: " . json_encode($acf_state));
|
||||
if ($acf_state !== null) {
|
||||
return $acf_state;
|
||||
}
|
||||
@@ -127,6 +128,7 @@ function is_predefined_acf_state($acf_field, $acf_value) {
|
||||
}
|
||||
function set_acf_field_CIPF($acf_field, $acf_value, $acf_id) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_history = Cipf::ACF_HISTORY;
|
||||
|
||||
/*
|
||||
* if acf_value is the name of a key in const acf_field,
|
||||
@@ -140,12 +142,24 @@ function set_acf_field_CIPF($acf_field, $acf_value, $acf_id) {
|
||||
else {
|
||||
$value = $acf_value;
|
||||
}
|
||||
error_log("acf_field: " . json_encode($acf_field));
|
||||
update_field($acf_field['_name'], $value, $acf_id);
|
||||
|
||||
/*
|
||||
* create history
|
||||
*
|
||||
*/
|
||||
$old_history = get_acf_field_CIPF($acf_history, $acf_id);
|
||||
$france_timezone = new DateTimeZone("Europe/Paris");
|
||||
$date_now = date_create('now', $france_timezone)->format('d/m/Y H:i:s');
|
||||
$acf_field_name = $acf_field['_name'];
|
||||
$history = "- [$date_now] '$acf_field_name' : '$value'
|
||||
";
|
||||
$history .= $old_history;
|
||||
update_field($acf_history['_name'], $history, $acf_id);
|
||||
}
|
||||
function get_acf_field_CIPF($acf_field, $state_name, $acf_id) {
|
||||
function get_acf_field_CIPF($acf_field, $acf_id) {
|
||||
Plgntls::debug_infos();
|
||||
return get_field_init_CIPF($acf_field, $acf_id);
|
||||
return get_field_init_CIPF($acf_field['_name'], $acf_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user