From a8e239b6603e24523eb5871fc291d37cafb90e3a Mon Sep 17 00:00:00 2001 From: Ruben Ramirez Date: Fri, 4 Apr 2025 00:35:26 -0500 Subject: [PATCH] Feat: Implement Credit Management UI (Step 11) - Theme fixes --- functions.php | 6 ++++-- template-manage-credits.php | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/functions.php b/functions.php index a1445e9..7119b36 100644 --- a/functions.php +++ b/functions.php @@ -241,8 +241,10 @@ function quiztech_handle_credit_purchase_submission() { } // Check if the plugin function exists and call it - if ( function_exists( 'quiztech_initiate_credit_purchase' ) ) { - $result = quiztech_initiate_credit_purchase( $user_id, $credit_amount, $price, $currency, $package_id ); + // Note: The plugin function expects (user_id, item_id, quantity) + if ( function_exists( '\Quiztech\AssessmentPlatform\Includes\quiztech_initiate_credit_purchase' ) ) { + // Pass package_id as item_id, quantity is 1 for these packages + $result = \Quiztech\AssessmentPlatform\Includes\quiztech_initiate_credit_purchase( $user_id, $package_id, 1 ); // If the function returns an error, redirect back with the message if ( is_wp_error( $result ) ) { diff --git a/template-manage-credits.php b/template-manage-credits.php index dfdd375..9ffa104 100644 --- a/template-manage-credits.php +++ b/template-manage-credits.php @@ -21,7 +21,8 @@ if ( ! is_user_logged_in() || ! current_user_can( $required_capability ) ) { // Get current user's credit balance $user_id = get_current_user_id(); -$current_balance = function_exists('quiztech_get_credit_balance') ? quiztech_get_credit_balance( $user_id ) : __( 'N/A (Function not found)', 'quiztech' ); +// Use the fully qualified function name including the namespace +$current_balance = function_exists('\Quiztech\AssessmentPlatform\Includes\quiztech_get_user_credit_balance') ? \Quiztech\AssessmentPlatform\Includes\quiztech_get_user_credit_balance( $user_id ) : __( 'N/A (Function not found)', 'quiztech' ); get_header(); ?>