Skip to content

Commit

Permalink
Merge branch 'stripe-prices-refactor'
Browse files Browse the repository at this point in the history
  • Loading branch information
gbp committed Nov 22, 2024
2 parents a18450f + 246e735 commit 1d1412b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
26 changes: 26 additions & 0 deletions lib/helper_patches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,30 @@ def hidden_by_excel_analyzer?

prepend ExcelAnalyzerDisableContactUs
end

AlaveteliPro::PriceHelper.class_eval do
module AlternativePriceText
def short_alternative_price_text(price)
amount = format_currency(
price.unit_amount_with_tax, no_cents_if_whole: true
)

if interval(price) == 'day' && interval_count(price) == 1
_('or {{amount}} daily', amount: amount)
elsif interval(price) == 'week' && interval_count(price) == 1
_('or {{amount}} weekly', amount: amount)
elsif interval(price) == 'month' && interval_count(price) == 1
_('or {{amount}} monthly', amount: amount)
elsif interval(price) == 'year' && interval_count(price) == 1
_('or {{amount}} annually', amount: amount)
else
_('or {{amount}} every {{interval}}',
amount: amount,
interval: pluralize_interval(price))
end
end
end

prepend AlternativePriceText
end
end
22 changes: 7 additions & 15 deletions lib/views/alaveteli_pro/plans/_pricing_tiers.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,15 @@
</p>

<p class="price-label">
<% if @plans[0].interval == 'month' %>
<%= _('<span class="price-label__amount">{{monthly_price}}</span> ' \
'per user, per month',
monthly_price: format_currency(
@plans[0].amount_with_tax,
no_cents_if_whole: true)) %>
<% elsif @plans[0].interval == 'year' %>
<%= _('<span class="price-label__amount">{{yearly_price}}</span> ' \
'per user, per year',
yearly_price: format_currency(
@plans[0].amount_with_tax,
no_cents_if_whole: true)) %>
<% end %>
<span class="price-label__amount">
<%= format_currency(@prices[0].unit_amount_with_tax, no_cents_if_whole: true) %>
</span>

<%= billing_interval(@prices[0]) %>
</p>

<p class="price-label-option">
<%= link_to _('or £100 annually'), plan_path('pro-annual-billing') %>
<%= link_to short_alternative_price_text(@prices[1]), plan_path(@prices[1]) %>
</p>
</div>

Expand All @@ -38,7 +30,7 @@
<li><%= _('Friendly support') %></li>
</ul>

<%= link_to _('Sign up'), plan_path('pro'), class: 'button button-pop' %>
<%= link_to _('Sign up'), plan_path(@prices[0]), class: 'button button-pop' %>
</div>
</div>
</div>

0 comments on commit 1d1412b

Please sign in to comment.