added change card prof 5€
This commit is contained in:
@@ -4,7 +4,7 @@ Plugin Name: hggg_cipf
|
||||
Plugin URI:
|
||||
Description:
|
||||
Author: hugogogo
|
||||
Version: 0.5.5
|
||||
Version: 0.5.6
|
||||
Author URI:
|
||||
*/
|
||||
|
||||
@@ -83,6 +83,7 @@ class Cipf {
|
||||
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'];
|
||||
const ACF_PROF_CHANGE_CARD = ['_name'=>'changement_de_carte'];
|
||||
|
||||
// META
|
||||
const META_PAYEMENT_STATUS = 'cipf_payement_status';
|
||||
@@ -205,6 +206,16 @@ contactez la fipf directement",
|
||||
'confirmation_subject'=>"[CIPF - virement validé]",
|
||||
'confirmation_message'=>"votre virement a été validé",
|
||||
],
|
||||
'change_card_success'=>[
|
||||
'name'=>'prof - le paiement pour changer la carte a réussi',
|
||||
'notification_send'=>true,
|
||||
'notification_to'=>'$$__admin_email__$$',
|
||||
'notification_subject'=>"[CIPF /prof - paiement changer carte reussi]",
|
||||
'notification_message'=>'paiement pour changer sa carte a réussi de la part de $$user_login$$ : $$__author_page_url__$$',
|
||||
'confirmation_send'=>true,
|
||||
'confirmation_subject'=>"[CIPF - paiement changement carte réussi]",
|
||||
'confirmation_message'=>"paiement changement carte réussi",
|
||||
],
|
||||
'account_deleted'=>[
|
||||
'name'=>'prof - le compte a été supprimé',
|
||||
'notification_send'=>true,
|
||||
|
||||
4
plugins/cipf_plugin/css/display_states/changer_carte.css
Normal file
4
plugins/cipf_plugin/css/display_states/changer_carte.css
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
[class*='cipf_display_'].cipf_display_changer_carte { display: block !important; }
|
||||
[class*='cipf_display_'].cipf_display_changer_carte.cipf_flex { display: flex !important; }
|
||||
|
||||
@@ -90,113 +90,6 @@ function send_emails_CIPF($email_name, $user_id = null) {
|
||||
}
|
||||
|
||||
|
||||
//function email_payment_success_CIPF($user_id = null) {
|
||||
// Plgntls::debug_infos();
|
||||
//error_log("email payment success: " . json_encode($email_payment_success));
|
||||
//
|
||||
// send_email_CIPF($email_payment_success, $user_id);
|
||||
// $user = get_user_by('id', $user_id);
|
||||
//// $to = $user->user_email;
|
||||
// $to = '$$__admin_email__$$';
|
||||
// $subject = 'My Custom Email Subject';
|
||||
// $message = 'Hello, This is a test email sent from my WordPress plugin!';
|
||||
// $headers = array('Content-Type: text/html; charset=UTF-8');
|
||||
//
|
||||
//
|
||||
// // Check if the email was sent successfully
|
||||
//}
|
||||
|
||||
/*
|
||||
'payment_success'=>[
|
||||
'notification_send'=>true,
|
||||
'notification_to'=>'$$__admin_email__$$',
|
||||
'notification_subject'=>"paiement réussi",
|
||||
'notification_message'=>"par ici la monnaie",
|
||||
'confirmation_send'=>true,
|
||||
'confirmation_subject'=>"paiement réussi",
|
||||
'confirmation_mesage'=>"donne l'argent",
|
||||
],
|
||||
// 2. profs : email : payment_failure : validation payment prof echec, send email
|
||||
'payment_echec'=>[
|
||||
'notification_send'=>true,
|
||||
'notification_to'=>'$$__admin_email__$$',
|
||||
'notification_subject'=>"",
|
||||
'notification_message'=>"",
|
||||
'confirmation_send'=>true,
|
||||
'confirmation_subject'=>"",
|
||||
'confirmation_mesage'=>"",
|
||||
],
|
||||
// 3. profs : email : transfert_success : validation transfert prof reussi, send email
|
||||
'transfert_success'=>[
|
||||
'notification_send'=>true,
|
||||
'notification_to'=>'$$__admin_email__$$',
|
||||
'notification_subject'=>"",
|
||||
'notification_message'=>"",
|
||||
'confirmation_send'=>true,
|
||||
'confirmation_subject'=>"",
|
||||
'confirmation_mesage'=>"",
|
||||
],
|
||||
// 4. profs : email : transfert_failures : validation transfert prof echec, send email
|
||||
'transfert_echec'=>[
|
||||
'notification_send'=>true,
|
||||
'notification_to'=>'$$__admin_email__$$',
|
||||
'notification_subject'=>"",
|
||||
'notification_message'=>"",
|
||||
'confirmation_send'=>true,
|
||||
'confirmation_subject'=>"",
|
||||
'confirmation_mesage'=>"",
|
||||
],
|
||||
// 5. partners : email : offer_expired : offres temporaires -> gerer qu'elles disparaissent apres la date de validite -> la passer en masquer
|
||||
'offer_expired'=>[
|
||||
'notification_send'=>true,
|
||||
'notification_to'=>'$$__admin_email__$$',
|
||||
'notification_subject'=>"",
|
||||
'notification_message'=>"",
|
||||
'confirmation_send'=>true,
|
||||
'confirmation_subject'=>"",
|
||||
'confirmation_mesage'=>"",
|
||||
],
|
||||
// 6. partners : email : offer_will_expire : la gestion des offres à échéance
|
||||
'offer_will_expire'=>[
|
||||
'notification_send'=>true,
|
||||
'notification_to'=>'$$__admin_email__$$',
|
||||
'notification_subject'=>"",
|
||||
'notification_message'=>"",
|
||||
'confirmation_send'=>true,
|
||||
'confirmation_subject'=>"",
|
||||
'confirmation_mesage'=>"",
|
||||
],
|
||||
// 7. payments : email : account_deleted : schedule event pour supprimer le compte xx temps (6 mois ?) apres fin de validite de la carte
|
||||
'account_deleted'=>[
|
||||
'notification_send'=>true,
|
||||
'notification_to'=>'$$__admin_email__$$',
|
||||
'notification_subject'=>"",
|
||||
'notification_message'=>"",
|
||||
'confirmation_send'=>true,
|
||||
'confirmation_subject'=>"",
|
||||
'confirmation_mesage'=>"",
|
||||
],
|
||||
// 8. payments : email : account_will_expire : faire rappels emails avant expiration
|
||||
'eccount_will_expire'=>[
|
||||
'notification_send'=>true,
|
||||
'notification_to'=>'$$__admin_email__$$',
|
||||
'notification_subject'=>"",
|
||||
'notification_message'=>"",
|
||||
'confirmation_send'=>true,
|
||||
'confirmation_subject'=>"",
|
||||
'confirmation_mesage'=>"",
|
||||
],
|
||||
// 9. payments : email : account_expired : desactiver carte expiree
|
||||
'account_expired'=>[
|
||||
'notification_send'=>true,
|
||||
'notification_to'=>'$$__admin_email__$$',
|
||||
'notification_subject'=>"",
|
||||
'notification_message'=>"",
|
||||
'confirmation_send'=>true,
|
||||
'confirmation_subject'=>"",
|
||||
'confirmation_mesage'=>"",
|
||||
],
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ if (!defined('ABSPATH')) {
|
||||
*
|
||||
* [/] card price ('somme_a_regler')
|
||||
*
|
||||
* [/] prof change card ('changement_de_carte')
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -55,6 +57,7 @@ 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;
|
||||
}
|
||||
@@ -69,6 +72,8 @@ function get_field_init_CIPF($acf_field_name, $acf_id) {
|
||||
update_field($acf_field_name, '', $acf_id);
|
||||
$acf_object = get_field_object($acf_field_name, $acf_id);
|
||||
|
||||
error_log("acf_object: " . json_encode($acf_object));
|
||||
|
||||
$default = '';
|
||||
if (isset($acf_object['default_value'])) {
|
||||
$default = $acf_object['default_value'];
|
||||
@@ -549,6 +554,9 @@ function reset_acf_cgv_CIPF($user_id = null) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* card price
|
||||
*
|
||||
@@ -563,6 +571,65 @@ function get_card_price_CIPF($user_id = null) {
|
||||
$acf_id = 'user_'.$user_id;
|
||||
return get_acf_field_CIPF($acf_card_price_total, $acf_id);
|
||||
}
|
||||
//function set_card_price_CIPF($value, $user_id = null) {
|
||||
// Plgntls::debug_infos();
|
||||
// $acf_card_price_total = Cipf::ACF_CARD_PRICE_TOTAL;
|
||||
//
|
||||
// if (is_null($user_id)) {
|
||||
// $user_id = get_current_user_id();
|
||||
// }
|
||||
// $acf_id = 'user_'.$user_id;
|
||||
// set_acf_field_CIPF($acf_card_price_total, $value, $acf_id);
|
||||
//}
|
||||
//function reset_card_price_CIPF($user_id = null) {
|
||||
// Plgntls::debug_infos();
|
||||
// $acf_card_price_total = Cipf::ACF_CARD_PRICE_TOTAL;
|
||||
//
|
||||
// if (is_null($user_id)) {
|
||||
// $user_id = get_current_user_id();
|
||||
// }
|
||||
// $acf_id = 'user_'.$user_id;
|
||||
// set_acf_field_CIPF($acf_card_price_total, 0, $acf_id);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* prof change card
|
||||
*
|
||||
*/
|
||||
function reset_acf_prof_change_card_CIPF($user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_prof_change_card = Cipf::ACF_PROF_CHANGE_CARD;
|
||||
|
||||
if (is_null($user_id)) {
|
||||
$user_id = get_current_user_id();
|
||||
}
|
||||
$acf_id = 'user_'.$user_id;
|
||||
set_acf_field_CIPF($acf_prof_change_card, false, $acf_id);
|
||||
}
|
||||
function set_acf_prof_change_card_CIPF($user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_prof_change_card = Cipf::ACF_PROF_CHANGE_CARD;
|
||||
|
||||
if (is_null($user_id)) {
|
||||
$user_id = get_current_user_id();
|
||||
}
|
||||
$acf_id = 'user_'.$user_id;
|
||||
set_acf_field_CIPF($acf_prof_change_card, true, $acf_id);
|
||||
}
|
||||
function is_acf_prof_change_card_CIPF($user_id = null) {
|
||||
Plgntls::debug_infos();
|
||||
$acf_prof_change_card = Cipf::ACF_PROF_CHANGE_CARD;
|
||||
|
||||
if (is_null($user_id)) {
|
||||
$user_id = get_current_user_id();
|
||||
}
|
||||
$acf_id = 'user_'.$user_id;
|
||||
return is_acf_field_CIPF($acf_prof_change_card, true, $acf_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -92,6 +92,14 @@ function display_states_css_CIPF($user_id = null) {
|
||||
$css_for_states[] = 'css/display_states/type_virement.css';
|
||||
}
|
||||
|
||||
/*
|
||||
* prof change carte
|
||||
*
|
||||
*/
|
||||
if (is_acf_prof_change_card_CIPF($user_id)) {
|
||||
$css_for_states[] = 'css/display_states/changer_carte.css';
|
||||
}
|
||||
|
||||
/*
|
||||
* page partenaire
|
||||
* - 'Publiee'
|
||||
|
||||
@@ -10,6 +10,27 @@ if (!defined('ABSPATH')) {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* action to be done at the init state of the page
|
||||
*
|
||||
*/
|
||||
function prof_payment_page_init_CIPF() {
|
||||
Plgntls::debug_infos(2);
|
||||
|
||||
if (!is_prof_CIPF()) {
|
||||
return;
|
||||
}
|
||||
Plgntls::debug_infos();
|
||||
|
||||
// https://developer.wordpress.org/reference/functions/get_query_var/#more-information
|
||||
global $wp;
|
||||
$wp->add_query_var('prof_card_change');
|
||||
}
|
||||
add_action('init','prof_payment_page_init_CIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@@ -29,7 +50,18 @@ function payment_page_checks_CIPF() {
|
||||
// get the user id
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
// do checks here
|
||||
/*
|
||||
* check for query card change
|
||||
* and modify acf field accordingly
|
||||
*
|
||||
*/
|
||||
$is_card_change = get_query_var('prof_card_change', false);
|
||||
if ($is_card_change == true) {
|
||||
set_acf_prof_change_card_CIPF();
|
||||
}
|
||||
else {
|
||||
reset_acf_prof_change_card_CIPF();
|
||||
}
|
||||
}
|
||||
add_action('wp', 'payment_page_checks_CIPF');
|
||||
|
||||
@@ -37,6 +69,8 @@ add_action('wp', 'payment_page_checks_CIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* only profs can access this page
|
||||
*
|
||||
|
||||
@@ -24,8 +24,6 @@ function paypal_shortcode_content_CIPF() {
|
||||
$paypal_message_failure = get_payment_message_failure_CIPF();
|
||||
$paypal_message_problem = get_payment_message_problem_CIPF();
|
||||
|
||||
// if (!can_pay_now_CIPF())
|
||||
// return no_payment_CIPF();
|
||||
|
||||
$pp_client_id = $paypal_client_id;
|
||||
$pp_sdk_currency = "EUR";
|
||||
@@ -55,10 +53,6 @@ function paypal_shortcode_content_CIPF() {
|
||||
add_shortcode('cipf_paypal_shortcode', 'paypal_shortcode_content_CIPF');
|
||||
|
||||
|
||||
function no_payment_CIPF() {
|
||||
Plgntls::debug_infos();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -128,11 +128,26 @@ function failure_payment_for_user_CIPF($user_id, $order_id, $status) {
|
||||
|
||||
schedule_delete_orderid_CIPF($order_id, $user_id);
|
||||
set_payment_failure_CIPF($user_id);
|
||||
set_account_to_pay_CIPF($user_id);
|
||||
send_emails_CIPF('payment_echec', $user_id);
|
||||
|
||||
/*
|
||||
* if payment was only for card change
|
||||
*
|
||||
*/
|
||||
if (is_acf_prof_change_card_CIPF($user_id)) {
|
||||
reset_acf_prof_change_card_CIPF($user_id);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* else
|
||||
*
|
||||
*/
|
||||
set_account_to_pay_CIPF($user_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* things to do when a payment is a success
|
||||
*
|
||||
@@ -141,9 +156,24 @@ function success_payment_for_user_CIPF($user_id, $order_id) {
|
||||
Plgntls::debug_infos();
|
||||
|
||||
schedule_delete_orderid_CIPF($order_id, $user_id);
|
||||
|
||||
/*
|
||||
* if payment was only for card change
|
||||
*
|
||||
*/
|
||||
if (is_acf_prof_change_card_CIPF($user_id)) {
|
||||
reset_acf_prof_change_card_CIPF($user_id);
|
||||
send_emails_CIPF('change_card_success', $user_id);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* else
|
||||
*
|
||||
*/
|
||||
update_card_date_expiration_CIPF($user_id);
|
||||
|
||||
if (is_card_new_CIPF()) {
|
||||
if (is_card_new_CIPF($user_id)) {
|
||||
set_card_number_CIPF($user_id);
|
||||
set_card_renew_CIPF($user_id);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ function check_can_pay_CIPF() {
|
||||
|
||||
|
||||
|
||||
schedule_prof_account_deletion_CIPF($user_id);
|
||||
//schedule_prof_account_deletion_CIPF($user_id);
|
||||
|
||||
/*
|
||||
* check if payment is virement or immediat
|
||||
@@ -98,6 +98,16 @@ schedule_prof_account_deletion_CIPF($user_id);
|
||||
return new WP_Error('cannot_purchase', "price is 0, nothing to purchase");
|
||||
}
|
||||
|
||||
/*
|
||||
* if is new account and is only to change card
|
||||
*
|
||||
*/
|
||||
if (is_card_new_CIPF()) {
|
||||
if (is_acf_prof_change_card_CIPF()) {
|
||||
return new WP_Error('cannot_purchase', "account is new, you cannot change your card");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* date validity is empty
|
||||
|
||||
Reference in New Issue
Block a user