diff --git a/common/djangoapps/course_modes/models.py b/common/djangoapps/course_modes/models.py index b6f064eade2a..f49cc1ef43bd 100644 --- a/common/djangoapps/course_modes/models.py +++ b/common/djangoapps/course_modes/models.py @@ -928,6 +928,34 @@ def get_course_prices(course, verified_only=False): return registration_price, format_course_price(price) +def get_course_display_price(course): + """ + Return the course price using the paid mode's OWN currency (e.g. "₹1000"), + or 'Free' when there is no paid mode. + + Unlike get_course_prices(), this does not force PAID_COURSE_REGISTRATION_CURRENCY, + so courses priced in any currency (INR, EUR, ...) display correctly instead of "Free". + """ + from babel.numbers import get_currency_symbol + + paid_mode = None + for mode in CourseMode.modes_for_course(course.id): + if mode.min_price and mode.min_price > 0: + if mode.slug == CourseMode.VERIFIED: + paid_mode = mode + break + if paid_mode is None: + paid_mode = mode + + if not paid_mode: + # No paid mode: keep existing behaviour (handles cosmetic_display_price / "Free"). + _, price = get_course_prices(course) + return price + + symbol = get_currency_symbol((paid_mode.currency or 'usd').upper()) + return f"{symbol}{paid_mode.min_price}" + + def format_course_price(price): """ Return a formatted price for a course (a string preceded by correct currency, or 'Free'). diff --git a/openedx/core/djangoapps/courseware_api/views.py b/openedx/core/djangoapps/courseware_api/views.py index a5940d8a132e..33410ba0b8ed 100644 --- a/openedx/core/djangoapps/courseware_api/views.py +++ b/openedx/core/djangoapps/courseware_api/views.py @@ -25,7 +25,7 @@ from xmodule.modulestore.search import path_to_location from xmodule.x_module import PUBLIC_VIEW, STUDENT_VIEW -from common.djangoapps.course_modes.models import CourseMode, get_course_prices +from common.djangoapps.course_modes.models import CourseMode, get_course_prices, get_course_display_price from common.djangoapps.util.views import expose_header from lms.djangoapps.edxnotes.helpers import is_feature_enabled from lms.djangoapps.certificates.api import get_certificate_url @@ -499,10 +499,9 @@ def advertised_start(self): @property def course_price(self): """ - Returns the course price, formatted with the currency symbol. + Returns the course price, formatted with the course mode's own currency symbol. """ - _, course_price = get_course_prices(self.course) - return course_price + return get_course_display_price(self.course) @property def pre_requisite_courses(self):