+
+ % if content_gating_enabled or course_duration_limit_enabled:
+
\ No newline at end of file
diff --git a/lms/templates/course_modes/choose.html b/lms/templates/course_modes/choose.html
index 80dc286566..20ee9dcaf4 100644
--- a/lms/templates/course_modes/choose.html
+++ b/lms/templates/course_modes/choose.html
@@ -124,14 +124,7 @@ from openedx.core.djangolib.markup import HTML, Text
diff --git a/openedx/features/course_experience/static/course_experience/fixtures/course-currency-fragment.html b/openedx/features/course_experience/static/course_experience/fixtures/course-currency-fragment.html
index 9a65d28651..2bbec514f4 100644
--- a/openedx/features/course_experience/static/course_experience/fixtures/course-currency-fragment.html
+++ b/openedx/features/course_experience/static/course_experience/fixtures/course-currency-fragment.html
@@ -1,2 +1,3 @@
-
+Pursue a Verified Certificate($100 USD)
+Pursue a Verified Certificate($90 USD$100 USD)
diff --git a/openedx/features/course_experience/static/course_experience/js/currency.js b/openedx/features/course_experience/static/course_experience/js/currency.js
index be5c3c63a0..d9fa2a80ef 100644
--- a/openedx/features/course_experience/static/course_experience/js/currency.js
+++ b/openedx/features/course_experience/static/course_experience/js/currency.js
@@ -4,17 +4,28 @@ import $ from 'jquery'; // eslint-disable-line import/extensions
export class Currency { // eslint-disable-line import/prefer-default-export
- setPrice() {
+ editText(price) {
const l10nCookie = this.countryL10nData;
- const lmsregex = /(\$)(\d*)( USD)/g;
- const price = $('input[name="verified_mode"]').filter(':visible')[0];
- const regexMatch = lmsregex.exec(price.value);
- const dollars = parseFloat(regexMatch[2]);
- const converted = dollars * l10nCookie.rate;
- const string = `${l10nCookie.symbol}${Math.round(converted)} ${l10nCookie.code}`;
- // Use regex to change displayed price on track selection
- // based on edx-price-l10n cookie currency_data
- price.value = price.value.replace(regexMatch[0], string);
+ const lmsregex = /(\$)([\d|.]*)( USD)/g;
+ const priceText = price.text();
+ const regexMatch = lmsregex.exec(priceText);
+ if (regexMatch) {
+ const currentPrice = regexMatch[2];
+ const dollars = parseFloat(currentPrice);
+ const newPrice = dollars * l10nCookie.rate;
+ const newPriceString = `${l10nCookie.symbol}${Math.round(newPrice)} ${l10nCookie.code}`;
+ // Change displayed price based on edx-price-l10n cookie currency_data
+ price.text(newPriceString);
+ }
+ }
+
+ setPrice() {
+ $('.upgrade-price-string').each((i, price) => {
+ // When the button includes two prices (discounted and previous)
+ // we call the method twice, since it modifies one price at a time.
+ // Could also be used to modify all prices on any page
+ this.editText($(price));
+ });
}
getCountry() {
diff --git a/openedx/features/course_experience/static/course_experience/js/spec/Currency_spec.js b/openedx/features/course_experience/static/course_experience/js/spec/Currency_spec.js
index f6f57de098..45e59ee254 100644
--- a/openedx/features/course_experience/static/course_experience/js/spec/Currency_spec.js
+++ b/openedx/features/course_experience/static/course_experience/js/spec/Currency_spec.js
@@ -36,12 +36,17 @@ describe('Currency factory', () => {
it('when location is the default (US)', () => {
$.cookie('edx-price-l10n', '{"rate":1,"code":"USD","symbol":"$","countryCode":"US"}', { path: '/' });
currency = new Currency();
- expect($('input[name="verified_mode"]').filter(':visible')[0].value).toEqual('Pursue a Verified Certificate ($100 USD)');
+ expect($('[name="verified_mode"].no-discount').filter(':visible').text()).toEqual('Pursue a Verified Certificate($100 USD)');
});
it('when cookie is set to a different country', () => {
$.cookie('edx-price-l10n', '{"rate":2.2,"code":"CAD","symbol":"$","countryCode":"CAN"}', { expires: 1 });
currency = new Currency();
- expect($('input[name="verified_mode"]').filter(':visible')[0].value).toEqual('Pursue a Verified Certificate ($220 CAD)');
+ expect($('[name="verified_mode"].no-discount').filter(':visible').text()).toEqual('Pursue a Verified Certificate($220 CAD)');
+ });
+ it('when cookie is set to a different country with a discount', () => {
+ $.cookie('edx-price-l10n', '{"rate":2.2,"code":"CAD","symbol":"$","countryCode":"CAN"}', { expires: 1 });
+ currency = new Currency();
+ expect($('[name="verified_mode"].discount').filter(':visible').text()).toEqual('Pursue a Verified Certificate($198 CAD $220 CAD)');
});
});
});
diff --git a/themes/edx.org/lms/templates/course_modes/_upgrade_button.html b/themes/edx.org/lms/templates/course_modes/_upgrade_button.html
new file mode 100644
index 0000000000..c4482ab82c
--- /dev/null
+++ b/themes/edx.org/lms/templates/course_modes/_upgrade_button.html
@@ -0,0 +1,25 @@
+<%page args="content_gating_enabled, course_duration_limit_enabled, min_price, price_before_discount" expression_filter="h"/>
+
+<%!
+from django.utils.translation import ugettext as _
+from openedx.core.djangolib.markup import HTML, Text
+%>
+
+<%namespace name='static' file='../static_content.html'/>
+
+
+
+ % if content_gating_enabled or course_duration_limit_enabled:
+
+ ${_('Pursue the Verified Track')}
+ % else:
+
+ ${_('Pursue a Verified Certificate')}
+ % endif
+ % if price_before_discount:
+ ($${min_price} USD${Text('${price} USD').format(price=price_before_discount)})
+ % else:
+ ($${min_price} USD)
+ % endif
+
+
\ No newline at end of file
diff --git a/themes/edx.org/lms/templates/course_modes/choose.html b/themes/edx.org/lms/templates/course_modes/choose.html
index 557328a2e4..ea35afc96e 100644
--- a/themes/edx.org/lms/templates/course_modes/choose.html
+++ b/themes/edx.org/lms/templates/course_modes/choose.html
@@ -137,14 +137,7 @@ from openedx.core.djangolib.markup import HTML, Text