Feat: Implement Credit Management UI (Step 11) - Theme fixes

This commit is contained in:
Ruben Ramirez 2025-04-04 00:35:26 -05:00
parent 278b820b00
commit a8e239b660
2 changed files with 6 additions and 3 deletions

View file

@ -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 ) ) {

View file

@ -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(); ?>