File tree Expand file tree Collapse file tree
common/djangoapps/course_modes
openedx/core/djangoapps/courseware_api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -928,6 +928,34 @@ def get_course_prices(course, verified_only=False):
928928 return registration_price , format_course_price (price )
929929
930930
931+ def get_course_display_price (course ):
932+ """
933+ Return the course price using the paid mode's OWN currency (e.g. "₹1000"),
934+ or 'Free' when there is no paid mode.
935+
936+ Unlike get_course_prices(), this does not force PAID_COURSE_REGISTRATION_CURRENCY,
937+ so courses priced in any currency (INR, EUR, ...) display correctly instead of "Free".
938+ """
939+ from babel .numbers import get_currency_symbol
940+
941+ paid_mode = None
942+ for mode in CourseMode .modes_for_course (course .id ):
943+ if mode .min_price and mode .min_price > 0 :
944+ if mode .slug == CourseMode .VERIFIED :
945+ paid_mode = mode
946+ break
947+ if paid_mode is None :
948+ paid_mode = mode
949+
950+ if not paid_mode :
951+ # No paid mode: keep existing behaviour (handles cosmetic_display_price / "Free").
952+ _ , price = get_course_prices (course )
953+ return price
954+
955+ symbol = get_currency_symbol ((paid_mode .currency or 'usd' ).upper ())
956+ return f"{ symbol } { paid_mode .min_price } "
957+
958+
931959def format_course_price (price ):
932960 """
933961 Return a formatted price for a course (a string preceded by correct currency, or 'Free').
Original file line number Diff line number Diff line change 2525from xmodule .modulestore .search import path_to_location
2626from xmodule .x_module import PUBLIC_VIEW , STUDENT_VIEW
2727
28- from common .djangoapps .course_modes .models import CourseMode , get_course_prices
28+ from common .djangoapps .course_modes .models import CourseMode , get_course_prices , get_course_display_price
2929from common .djangoapps .util .views import expose_header
3030from lms .djangoapps .edxnotes .helpers import is_feature_enabled
3131from lms .djangoapps .certificates .api import get_certificate_url
@@ -499,10 +499,9 @@ def advertised_start(self):
499499 @property
500500 def course_price (self ):
501501 """
502- Returns the course price, formatted with the currency symbol.
502+ Returns the course price, formatted with the course mode's own currency symbol.
503503 """
504- _ , course_price = get_course_prices (self .course )
505- return course_price
504+ return get_course_display_price (self .course )
506505
507506 @property
508507 def pre_requisite_courses (self ):
You can’t perform that action at this time.
0 commit comments