diff --git a/app/assets/javascripts/directives/coupon.coffee.erb b/app/assets/javascripts/directives/coupon.coffee.erb index 00ad9984a..3101a7013 100644 --- a/app/assets/javascripts/directives/coupon.coffee.erb +++ b/app/assets/javascripts/directives/coupon.coffee.erb @@ -1,4 +1,4 @@ -Application.Directives.directive 'coupon', [ 'Coupon', 'growl', '_t', (Coupon, growl, _t) -> +Application.Directives.directive 'coupon', [ '$rootScope', 'Coupon', 'growl', '_t', ($rootScope, Coupon, growl, _t) -> { restrict: 'E' scope: @@ -35,7 +35,10 @@ Application.Directives.directive 'coupon', [ 'Coupon', 'growl', '_t', (Coupon, g Coupon.validate {code: $scope.couponCode, user_id: $scope.userId, amount: $scope.total}, (res) -> $scope.status = 'valid' $scope.coupon = res - growl.success(_t('the_coupon_has_been_applied_you_get_PERCENT_discount', {PERCENT: res.percent_off})) + if res.type == 'percent_off' + growl.success(_t('the_coupon_has_been_applied_you_get_PERCENT_discount', {PERCENT: res.percent_off})) + else + growl.success(_t('the_coupon_has_been_applied_you_get_DISCOUNT_CURRENCY', {DISCOUNT: res.amount_off, CURRENCY: $rootScope.currencySymbol})) , (err) -> $scope.status = 'invalid' $scope.coupon = null diff --git a/config/locales/app.shared.en.yml b/config/locales/app.shared.en.yml index 6ba0e3785..470a94a2a 100644 --- a/config/locales/app.shared.en.yml +++ b/config/locales/app.shared.en.yml @@ -367,7 +367,8 @@ en: # coupon (input zone for users) i_have_a_coupon: "I have a coupon!" code_: "Code:" - the_coupon_has_been_applied_you_get_PERCENT_discount: "The coupon has been applied. You get {{PERCENT}}% discount." # angular interpolation + the_coupon_has_been_applied_you_get_PERCENT_discount: "The coupon has been applied. You get a {{PERCENT}}% discount." # angular interpolation + the_coupon_has_been_applied_you_get_DISCOUNT_CURRENCY: "The coupon has been applied. You get a discount of {{DISCOUNT}} {{CURRENCY}}." # angular interpolation unable_to_apply_the_coupon_because_disabled: "Unable to apply the coupon: this code was disabled." unable_to_apply_the_coupon_because_expired: "Unable to apply the coupon: this code has expired." unable_to_apply_the_coupon_because_sold_out: "Unable to apply the coupon: this code reached its quota." diff --git a/config/locales/app.shared.fr.yml b/config/locales/app.shared.fr.yml index eb7634740..0fe631285 100644 --- a/config/locales/app.shared.fr.yml +++ b/config/locales/app.shared.fr.yml @@ -368,6 +368,7 @@ fr: i_have_a_coupon: "J'ai un code promo !" code_: "Code :" the_coupon_has_been_applied_you_get_PERCENT_discount: "Le code promo a bien été appliqué. Vous bénéficiez d'une remise de {{PERCENT}} %." # angular interpolation + the_coupon_has_been_applied_you_get_DISCOUNT_CURRENCY: "Le code promo a bien été appliqué. Vous bénéficiez d'une remise de {{DISCOUNT}} {{CURRENCY}}." # angular interpolation unable_to_apply_the_coupon_because_disabled: "Impossible d'appliquer la réduction : ce code promo a été désactivé." unable_to_apply_the_coupon_because_expired: "Impossible d'appliquer la réduction : ce code promo a expiré." unable_to_apply_the_coupon_because_sold_out: "Impossible d'appliquer la réduction : ce code promo a atteint son quota."