Skip to content

Commit

Permalink
Merge pull request #2485 from QuizandSurveyMaster/CU-867968jpx-email-…
Browse files Browse the repository at this point in the history
…and-result-page-redesign

fixed email send issue
  • Loading branch information
zubairraeen authored Mar 8, 2024
2 parents 9a9b496 + 836e952 commit f46a18f
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions php/classes/class-qsm-emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,38 @@ public static function send_emails( $transient_id ) {
// Cycle through each condition to see if we should sent this email.
foreach ( $email['conditions'] as $condition ) {
$value = $condition['value'];
$category = '';
if ( isset( $condition['category'] ) ) {
$category = $condition['category'];
$main_condition = '';
if ( isset($condition['category']) ) {
$main_condition = $condition['category'];
}
if ( ! empty($condition['extra_condition']) && 'category' == $main_condition ) {
$category = $condition['extra_condition'];
if ( str_contains($category, 'qsm-cat-') ) {
$cat_id = intval( str_replace( 'qsm-cat-', '', $category ) );
$term = get_term( $cat_id );
if ( $term ) {
$category = $term->name;
}
}
}else {
$category = $main_condition;
}
// First, determine which value we need to test.
switch ( $condition['criteria'] ) {
case 'score':
if ( '' !== $category ) {
$test = apply_filters( 'mlw_qmn_template_variable_results_page', "%CATEGORY_SCORE_$category%", $response_data );
} else {
if ( '' == $main_condition || 'quiz' == $main_condition ) {
$test = $response_data['total_score'];
} else {
$test = apply_filters( 'mlw_qmn_template_variable_results_page', "%CATEGORY_SCORE_$category%", $response_data );
}

break;

case 'points':
if ( '' !== $category ) {
$test = apply_filters( 'mlw_qmn_template_variable_results_page', "%CATEGORY_POINTS_$category%", $response_data );
} else {
if ( '' == $main_condition || 'quiz' == $main_condition ) {
$test = $response_data['total_points'];
} else {
$test = apply_filters( 'mlw_qmn_template_variable_results_page', "%CATEGORY_POINTS_$category%", $response_data );
}
break;

Expand Down

0 comments on commit f46a18f

Please sign in to comment.