function process_purchase($id) { $user_id = wp_get_current_user()->ID; $currency = get_currency_available(); $item = get_item($id); $price = $item->price; if (intval($price) > intval($currency)) { return false; } else { $purchase_id = create_purchase($user_id); create_line_item($purchase_id, $id, $price); $cost = floatval($price) * -1; bonus_points_to_wallet($user_id, $cost); return true; } }
function add_user_progress_with_bonus($user_id, $hotspot_id, $domain_id, $bonus_points) { global $wpdb; // Assign variables for the query $uid = $user_id; $sid = $hotspot_id; $tid = $domain_id; // Get the table names for the query $progress_table = get_user_skill_bonus_pts_table_name(); // Insert the progress $wpdb->insert($progress_table, array('user_id' => $uid, 'skill_id' => $sid, 'domain_id' => $tid, 'bonus_points' => $bonus_points), array('%s', '%d')); bonus_points_to_wallet($uid, $bonus_points); // Get the id of the last row $lastid = $wpdb->insert_id; // Get the points that were just added $pano = $wpdb->get_row($wpdb->prepare("SELECT wpup.`bonus_points`\n FROM " . $progress_table . " wpup\n WHERE wpup.`id` = %d", $lastid)); // Return those points return $pano->bonus_points; }