Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Fixed translations, completed gift card page
Damian Legawiec5576952743c5
diff --git a/admin/app/controllers/spree/admin/gift_cards_controller.rb b/admin/app/controllers/spree/admin/gift_cards_controller.rbindex eda64e769a..5a69cae5a1 100644--- a/admin/app/controllers/spree/admin/gift_cards_controller.rb+++ b/admin/app/controllers/spree/admin/gift_cards_controller.rb@@ -3,6 +3,7 @@ module Spreeclass GiftCardsController < ResourceControllerbefore_action :load_userbefore_action :add_breadcrumbs+ before_action :load_orders, only: :showhelper_method :gift_cards_filter_dropdown_value@@ -65,7 +66,7 @@ module Spreewhen 'active'Spree.t('admin.gift_cards.active')when 'expired'- Spree.t('admin.gift_cards.expired')+ Spree.t(:expired)when 'redeemed'Spree.t('admin.gift_cards.redeemed')else@@ -84,6 +85,10 @@ module Spreeadd_breadcrumb Spree.t(:gift_cards), :admin_gift_cards_pathendend++ def load_orders+ @orders = @object.orders.includes(:user).order(created_at: :desc)+ endendendenddiff --git a/admin/app/views/spree/admin/gift_cards/_list.html.erb b/admin/app/views/spree/admin/gift_cards/_list.html.erbindex ae660132a4..3877d6acc2 100644--- a/admin/app/views/spree/admin/gift_cards/_list.html.erb+++ b/admin/app/views/spree/admin/gift_cards/_list.html.erb@@ -9,7 +9,7 @@<th><%= Spree.t(:currency) %></th><th><%= Spree.t(:status) %></th><th><%= Spree.t(:expires_at) %></th>- <th><%= Spree.t('admin.gift_cards.issued_to') %></th>+ <th><%= Spree.t(:customer) %></th></tr></thead><tbody>diff --git a/admin/app/views/spree/admin/gift_cards/_table_filter_dropdown.html.erb b/admin/app/views/spree/admin/gift_cards/_table_filter_dropdown.html.erbindex a8f94bdfd0..047c0b1e51 100644--- a/admin/app/views/spree/admin/gift_cards/_table_filter_dropdown.html.erb+++ b/admin/app/views/spree/admin/gift_cards/_table_filter_dropdown.html.erb@@ -13,7 +13,7 @@<%= link_to params.to_unsafe_h.deep_merge({page: nil, q: {status_eq: :expired}}),class: "dropdown-item #{'active' if params[:q] && params[:q][:status_eq] == 'expired'}" do %>- <%= Spree.t('admin.gift_cards.expired') %>+ <%= Spree.t(:expired) %><% end %><%= link_to params.to_unsafe_h.deep_merge({page: nil, q: {status_eq: :redeemed}}),diff --git a/admin/app/views/spree/admin/gift_cards/edit.html.erb b/admin/app/views/spree/admin/gift_cards/edit.html.erbindex f4daa179f3..604b57de22 100644--- a/admin/app/views/spree/admin/gift_cards/edit.html.erb+++ b/admin/app/views/spree/admin/gift_cards/edit.html.erb@@ -1,6 +1,20 @@<%= turbo_frame_tag :gift_card_settings do %>- <%= render partial: 'spree/admin/shared/error_messages', locals: { target: @object } %><%= form_for [:admin, @user, @object] do |f| %>- <%= render 'form', f: f %>+ <div class="card">+ <div class="card-header d-flex justify-content-between">+ <h5 class="card-title">+ <%= Spree.t(:settings) %>+ </h5>+ </div>+ <div class="card-body">+ <%= render partial: 'spree/admin/shared/error_messages', locals: { target: @object } %>+ <%= render 'form', f: f %>+ </div>+ <div class="card-footer d-flex justify-content-between">+ <%= turbo_save_button_tag Spree.t('actions.update') %>++ <%= link_to Spree.t('actions.discard'), spree.admin_gift_card_path(@object), class: 'btn btn-light' %>+ </div>+ </div><% end %><% end %>diff --git a/admin/app/views/spree/admin/gift_cards/index.csv.erb b/admin/app/views/spree/admin/gift_cards/index.csv.erbindex 095df7ab73..22229c793b 100644--- a/admin/app/views/spree/admin/gift_cards/index.csv.erb+++ b/admin/app/views/spree/admin/gift_cards/index.csv.erb@@ -1,14 +1,22 @@<%- headers = [- 'Code', 'Amount', 'Minimum Order Amount', 'Used', 'Status', 'Expires At'+ Spree.t(:code),+ Spree.t(:amount),+ Spree.t(:used),+ Spree.t(:currency),+ Spree.t(:status),+ Spree.t(:expires_at),+ Spree.t(:customer)]-%><%= CSV.generate_line(headers).strip %><%- @collection.find_each do |gift_card| -%><%= CSV.generate_line([- gift_card.code.upcase,- gift_card.amount.to_f,- gift_card.amount_used.to_f,+ gift_card.display_code,+ gift_card.display_amount,+ gift_card.display_amount_used,+ gift_card.currency,gift_card.display_state,gift_card.expires_at,+ gift_card.user&.email,]).strip.html_safe %><%- end -%>diff --git a/admin/app/views/spree/admin/gift_cards/index.html.erb b/admin/app/views/spree/admin/gift_cards/index.html.erbindex a64125418a..ef0f3f1ee4 100644--- a/admin/app/views/spree/admin/gift_cards/index.html.erb+++ b/admin/app/views/spree/admin/gift_cards/index.html.erb@@ -10,7 +10,7 @@<% end %><div class="dropdown" id="page_actions_dropdown">- <%= link_to_with_icon 'plus', 'Add a new gift card', '#', class: 'text-nowrap btn btn-primary align-self-center', data: { toggle: 'dropdown' }, id: 'more-actions-link' %>+ <%= link_to_with_icon 'plus', Spree.t(:new_gift_card), '#', class: 'text-nowrap btn btn-primary align-self-center', data: { toggle: 'dropdown' }, id: 'more-actions-link' %><div class="dropdown-menu dropdown-menu-right"><%= link_to spree.new_admin_gift_card_path,class: 'text-left dropdown-item' do %>diff --git a/admin/app/views/spree/admin/gift_cards/new.html.erb b/admin/app/views/spree/admin/gift_cards/new.html.erbindex 18d2238bee..be4daac5d8 100644--- a/admin/app/views/spree/admin/gift_cards/new.html.erb+++ b/admin/app/views/spree/admin/gift_cards/new.html.erb@@ -5,7 +5,7 @@<%= page_header_back_button spree.admin_gift_cards_path %><% end %>- <%= Spree.t('admin.gift_cards.new_gift_card') %>+ <%= Spree.t(:new_gift_card) %><% end %><% url = @user.present? ? spree.admin_user_gift_cards_path(@user) : spree.admin_gift_cards_path %>@@ -17,7 +17,7 @@<div class="card mb-4"><div class="card-header"><h5 class="card-title">- <%= Spree.t(:gift_card) %>+ <%= Spree.t(:new_gift_card) %></h5></div><div class="card-body">diff --git a/admin/app/views/spree/admin/gift_cards/show.html.erb b/admin/app/views/spree/admin/gift_cards/show.html.erbindex 257a96dff3..970d07339b 100644--- a/admin/app/views/spree/admin/gift_cards/show.html.erb+++ b/admin/app/views/spree/admin/gift_cards/show.html.erb@@ -7,11 +7,12 @@<%= @object.code.upcase %><span class="badge">- <%= active_badge(@object.active?, label: @object.display_state) %>+ <%= active_badge(@object.active?, label: @object.display_state, class: 'badge-sm') %></span><% end %><% content_for :title do %>+ <%= Spree.t(:gift_card) %><%= @object.code.upcase %><% end %>@@ -21,7 +22,7 @@<div class="card mb-4"><div class="card-header d-flex justify-content-between align-items-center"><h5 class="card-title">- Gift card usage details+ <%= Spree.t('admin.gift_cards.usage') %></h5></div><div class="card-body border-bottom">@@ -30,27 +31,58 @@<%= progress_bar_component(@object.amount_used, max: @object.amount) %></div><div class="w-25 text-right">+ <%= @object.display_amount_used %> <%= Spree.t(:used).downcase %> / <%= @object.display_amount %></div></div></div>- <div class="card-body">- <ul class="list-group pb-4">- <% @object.orders.each do |order| %>- <li class="list-group-item d-flex justify-content-between align-items-center">- <% if order %>- <%= link_to order.number, spree.edit_admin_order_path(order), class: 'text-dark font-weight-bold d-block w-20' %>- <% end %>- <div class="w-40 align-items-center">- <% if order.user %>- <%= order.user.email %>+ <div class="card-body p-0">+ <% if @orders.any? %>+ <div class="table-responsive">+ <table class="table">+ <thead>+ <tr>+ <th><%= Spree.t(:order) %></th>+ <th><%= Spree.t(:status) %></th>+ <th><%= Spree.t(:customer) %></th>+ <th class="text-right"><%= I18n.t('activerecord.attributes.spree/gift_card.amount_used') %></th>+ <th class="text-right"><%= Spree.t(:total) %></th>+ </tr>+ </thead>+ <tbody>+ <% @orders.each do |order| %>+ <tr>+ <td>+ <%= link_to order.number, spree.edit_admin_order_path(order), class: 'text-dark font-weight-bold' %>+ </td>+ <td>+ <% if order.completed? %>+ <span class="badge badge-success">+ <%= icon('check') %>+ <%= Spree.t("state_machine_states.completed") %>+ </span>+ <% else %>+ <span class="badge badge-warning">+ <%= Spree.t("state_machine_states.#{order.state}") %>+ </span>+ <% end %>+ </td>+ <td>+ <%= order.user.email %>+ </td>+ <td class="text-right">+ <%= order.display_gift_card_total %>+ </td>+ <td class="text-right">+ <%= order.display_total %>+ </td>+ </tr><% end %>- </div>- <span class="text-right w-20">- <%= order.display_total_applicable_store_credit %>- </span>- </li>- <% end %>- </ul>+ </tbody>+ </table>+ </div>+ <% else %>+ <%= render 'spree/admin/shared/no_resource_found', resource_name: Spree.t(:order), new_object_url: nil %>+ <% end %></div></div>@@ -67,6 +99,66 @@</div><div class="card-body p-0"><ul class="list-group list-group-flush">+ <li class="list-group-item d-flex justify-content-between align-items-center">+ <span class="text-muted">+ <%= Spree.t(:code) %>+ </span>+ <span>+ <code><%= @object.display_code %></code>+ <%= clipboard_component(@object.display_code) %>+ </span>+ </li>++ <li class="list-group-item d-flex justify-content-between align-items-center">+ <span class="text-muted">+ <%= Spree.t(:customer) %>+ </span>+ <span>+ <% if @object.user %>+ <%= link_to @object.user.email, spree.admin_user_path(@object.user), data: { turbo_frame: '_top' } %>+ <% else %>+ <span class="text-muted">+ <%= Spree.t(:not_available) %>+ </span>+ <% end %>+ </span>+ </li>++ <li class="list-group-item d-flex justify-content-between align-items-center">+ <span class="text-muted">+ <%= Spree.t(:amount) %>+ </span>+ <span>+ <%= @object.display_amount %>+ </span>+ </li>+ <li class="list-group-item d-flex justify-content-between align-items-center">+ <span class="text-muted">+ <%= Spree.t(:used) %>+ </span>+ <span>+ <%= @object.display_amount_used %>+ </span>+ </li>++ <li class="list-group-item d-flex justify-content-between align-items-center">+ <span class="text-muted">+ <%= Spree.t('store_credit.remaining') %>+ </span>+ <span>+ <%= @object.display_amount_remaining %>+ </span>+ </li>++ <li class="list-group-item d-flex justify-content-between align-items-center">+ <span class="text-muted">+ <%= Spree.t(:currency) %>+ </span>+ <span>+ <%= @object.currency %>+ </span>+ </li>+<li class="list-group-item d-flex justify-content-between align-items-center"><span class="text-muted"><%= Spree.t(:expires_at) %>@@ -77,6 +169,28 @@<span class="text-muted"><%= Spree.t(:not_available) %></span><% end %></li>++ <li class="list-group-item d-flex justify-content-between align-items-center">+ <span class="text-muted">+ <%= Spree.t(:created_by) %>+ </span>+ <span>+ <% if @object.created_by %>+ <%= link_to @object.created_by.email, spree.admin_admin_user_path(@object.created_by), data: { turbo_frame: '_top' } %>+ <% else %>+ <span class="text-muted">+ <%= Spree.t(:not_available) %>+ </span>+ <% end %>+ </span>+ </li>++ <li class="list-group-item d-flex justify-content-between align-items-center">+ <span class="text-muted">+ <%= Spree.t(:created_at) %>+ </span>+ <span><%= local_time(@object.created_at) %></span>+ </li></ul></div></div>diff --git a/admin/app/views/spree/admin/users/index.html.erb b/admin/app/views/spree/admin/users/index.html.erbindex 1c5a2da887..da33cd69ba 100644--- a/admin/app/views/spree/admin/users/index.html.erb+++ b/admin/app/views/spree/admin/users/index.html.erb@@ -10,7 +10,7 @@<%= render 'extra_actions' %>- <%= link_to_with_icon 'plus', Spree.t(:create_customer), spree.new_admin_user_path, class: "btn btn-primary" if can? :create, Spree::user_class %>+ <%= link_to_with_icon 'plus', Spree.t(:new_customer), spree.new_admin_user_path, class: "btn btn-primary" if can? :create, Spree::user_class %><% end %><div class="card-lg">diff --git a/admin/app/views/spree/admin/users/show.html.erb b/admin/app/views/spree/admin/users/show.html.erbindex 1eb7b88972..920691475b 100644--- a/admin/app/views/spree/admin/users/show.html.erb+++ b/admin/app/views/spree/admin/users/show.html.erb@@ -8,8 +8,8 @@<% end %><% content_for(:page_actions_dropdown) do %>- <% if spree.respond_to?(:new_admin_user_gift_card_path) && can?(:create, Spree::GiftCard) %>- <%= link_to_with_icon 'plus', Spree.t(:issue_gift_card), spree.new_admin_user_gift_card_path(@user), class: 'text-left dropdown-item' %>+ <% if can?(:create, Spree::GiftCard) %>+ <%= link_to_with_icon 'plus', Spree.t(:add_gift_card), spree.new_admin_user_gift_card_path(@user), class: 'text-left dropdown-item' %><% end %><% if can?(:create, Spree::StoreCredit) %>diff --git a/admin/config/locales/en.yml b/admin/config/locales/en.ymlindex 990fc26c94..1afd65222b 100644--- a/admin/config/locales/en.yml+++ b/admin/config/locales/en.yml@@ -86,10 +86,8 @@ en:all: Allall_statuses: All statusescode_help_text: If you leave it blank, we will generate code for you- expired: Expired- issued_to: Issued to- new_gift_card: New gift cardredeemed: Redeemed+ usage: Usageintegrations:invalid_integration_type: This integration is not allowedpage_subtitle: Connect your store to third-party services to enhance customer experience.diff --git a/admin/spec/controllers/spree/admin/gift_cards_controller_spec.rb b/admin/spec/controllers/spree/admin/gift_cards_controller_spec.rbindex f12eb02de9..17afa9ac8e 100644--- a/admin/spec/controllers/spree/admin/gift_cards_controller_spec.rb+++ b/admin/spec/controllers/spree/admin/gift_cards_controller_spec.rb@@ -1,22 +1,18 @@require 'spec_helper'describe Spree::Admin::GiftCardsController, type: :controller do+ stub_authorization!render_viewslet(:store) { @default_store }- let(:admin_user) { create(:admin_user) }let(:user) { create(:user) }let(:gift_card) { create(:gift_card, user: user, created_by: admin_user) }- before do- allow(controller).to receive(:current_store).and_return(store)- allow(controller).to receive(:try_spree_current_user).and_return(admin_user)- end-describe '#index' dosubject { get :index }it 'renders the index template' do+ create_list(:gift_card, 3)subjectexpect(response).to render_template(:index)expect(response).to have_http_status(:ok)@@ -68,6 +64,22 @@ describe Spree::Admin::GiftCardsController, type: :controller doendendend++ context 'with CSV format' do+ it 'renders the CSV template' do+ gift_cards = create_list(:gift_card, 3)+ get :index, params: { format: :csv }+ expect(response).to render_template(:index)+ expect(response).to have_http_status(:ok)+ expect(response.body).to include("Code,Amount,Used,Currency,Status,Expires at,Customer")+ gift_cards.each do |gift_card|+ expect(response.body).to include(gift_card.display_code)+ expect(response.body).to include(gift_card.display_amount.to_html)+ expect(response.body).to include(gift_card.display_amount_used.to_html)+ expect(response.body).to include(gift_card.currency)+ end+ end+ endenddescribe '#show' dodiff --git a/core/config/locales/en.yml b/core/config/locales/en.ymlindex c818e23a89..3f0758e007 100644--- a/core/config/locales/en.yml+++ b/core/config/locales/en.yml@@ -51,6 +51,7 @@ en:verification_value: Verification Valueyear: Yearspree/gift_card:+ amount_used: Amount usedexpires_at: Expires atspree/inventory_unit:state: State@@ -588,6 +589,7 @@ en:add_address: Add addressadd_country: Add Countryadd_coupon_code: Add Coupon Code+ add_gift_card: Add Gift Cardadd_new_address: Add new addressadd_new_credit_card: Add a new cardadd_new_header: Add New Header@@ -675,6 +677,7 @@ en:api_keys: API keysapply: Applyapply_only_on_full_priced_items: Apply only on full priced items+ apply_store_credit: Apply Store Creditapprove: approveapproved_at: Approved atapprover: Approver@@ -852,10 +855,8 @@ en:coupon_codes: Coupon codescreate: Createcreate_a_new_account: Create a new account- create_customer: Create customercreate_new: Create newcreate_new_order: Create new order- create_new_team: Create new teamcreate_reimbursement: Create reimbursementcreated_at: Created atcreated_by: Created by@@ -873,7 +874,6 @@ en:currency_settings: Currency Settingscurrent: Currentcurrent_password: Current password- current_promotion_usage: 'current usage: %{count}'custom_code: Custom codecustom_font_code: Custom font codecustomer: Customer@@ -957,7 +957,7 @@ en:download: Downloaddraft: Draftdraft_mode: Draft Mode- draft_orders: Draft orders+ draft_orders: Draft Ordersduplicate: Duplicateduplicating: Duplicatingedit: Edit@@ -1096,7 +1096,7 @@ en:get_back_to_the: Get back to thegift_card: Gift Cardgift_card_applied: The Gift Card was successfully applied to your order!- gift_card_batch: Gift Card batch+ gift_card_batch: Gift Card Batchgift_card_removed: The Gift Card was successfully removed from your ordergift_card_using_store_credit_error: You can't apply the Gift Card after you applied the store credit.gift_cards: Gift Cards@@ -1190,7 +1190,6 @@ en:iso: ISO Alpha-2iso3: ISO Alpha-3iso_name: ISO Name- issue_gift_card: Issue a Gift Cardissued_on: Issued Onitem: Itemitem_description: Item Description@@ -1295,6 +1294,7 @@ en:new_customer_return: New Customer Returnnew_digital_asset: New digital assetnew_domain: New domain+ new_gift_card: New Gift Cardnew_image: New Imagenew_line_item: Add line itemnew_market: New market@@ -2025,7 +2025,6 @@ en:additional_payment_needed: Select another payment method for the remaining <strong>%{amount}</strong>.allocated: Addedapplicable_amount: "<strong>%{amount}</strong> in store credit will be applied to this order."- apply: Applyauthorized: Authorizedavailable_amount: You have <strong>%{amount}</strong> in Store Credit available!captured: Useddiff --git a/storefront/app/views/spree/checkout/_coupon_code.html.erb b/storefront/app/views/spree/checkout/_coupon_code.html.erbindex 7c62acc7d7..6dd55f77b6 100644--- a/storefront/app/views/spree/checkout/_coupon_code.html.erb+++ b/storefront/app/views/spree/checkout/_coupon_code.html.erb@@ -1,5 +1,5 @@<%= turbo_frame_tag :checkout_coupon_code, class: "shopping-cart-coupon-code #{local_assigns[:classes]} flex flex-col gap-3" do %>- <% if promotion.nil? %>+ <% if promotion.nil? && @order.gift_card.blank? %><%= form_tag spree.checkout_apply_coupon_code_path(@order.token), method: :patch, data: {controller: "checkout-promotions"} do %><div class="flex" data-controller="enable-button"><%= hidden_field_tag :promotion_email, @order.email, data: {checkout_promotions_target: 'promotionEmailField'} %>@@ -26,7 +26,7 @@</div></div><% end %>- <% elsif @order.respond_to?(:gift_card) && @order.gift_card %>+ <% elsif @order.gift_card.present? %><%= form_tag spree.checkout_remove_coupon_code_path(@order.token), method: :delete do %><%= hidden_field_tag :gift_card, @order.gift_card.code %><div class="m-0">diff --git a/storefront/app/views/spree/checkout/_store_credit.html.erb b/storefront/app/views/spree/checkout/_store_credit.html.erbindex 8990fb7fc7..8ab379d0af 100644--- a/storefront/app/views/spree/checkout/_store_credit.html.erb+++ b/storefront/app/views/spree/checkout/_store_credit.html.erb@@ -11,7 +11,7 @@<%= check_box_tag :store_credit, '1', @order.using_store_credit?,class: 'input-checkbox !border-neutral-200 rounded-md',data: { action: 'auto-submit#submit' } %>- <%= Spree.t("store_credit.apply") %>+ <%= Spree.t(:apply_store_credit) %><% end %><div><%= @order.display_total_available_store_credit %></div>