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
Add code from spree_wishlist gem
Matthew Kennedy12c311cc4192
diff --git a/api/app/controllers/spree/api/v2/storefront/wished_products_controller.rb b/api/app/controllers/spree/api/v2/storefront/wished_products_controller.rbnew file mode 100644index 0000000000..6fb21c7f9c--- /dev/null+++ b/api/app/controllers/spree/api/v2/storefront/wished_products_controller.rb@@ -0,0 +1,69 @@+module Spree+ module Api+ module V2+ module Storefront+ class WishedProductsController < ::Spree::Api::V2::BaseController++ def create+ spree_authorize! :create, Spree::WishedProduct+ spree_authorize! :update, wishlist++ wished_product = Spree::WishedProduct.new(wished_product_attributes)++ if wishlist.include? params[:wished_product][:variant_id]+ wished_product = wishlist.wished_products.detect {|wp| wp.variant_id == params[:wished_product][:variant_id].to_i }+ else+ wished_product.wishlist = wishlist+ wished_product.save+ end++ wishlist.reload+ if wished_product.persisted?+ render_serialized_payload { serialize_resource(wished_product) }+ else+ render_error_payload(wished_product.errors.full_messages.to_sentence)+ end+ end++ def update+ spree_authorize! :update, resource+ resource.update(wished_product_attributes)++ if resource.errors.empty?+ render_serialized_payload { serialize_resource(resource) }+ else+ render_error_payload(resource.errors.full_messages.to_sentence)+ end+ end++ def destroy+ spree_authorize! :destroy, resource+ if resource.destroy+ render_serialized_payload { serialize_resource(resource) }+ else+ render_error_payload('Something went wrong')+ end+ end++ private++ def resource+ @resource ||= wishlist.wished_products.find(params[:id])+ end++ def wishlist+ @wishlist ||= Spree::Wishlist.find_by!(access_hash: params[:wishlist_id])+ end++ def wished_product_attributes+ params.require(:wished_product).permit(:variant_id, :quantity, :remark)+ end++ def resource_serializer+ ::Spree::V2::Storefront::WishedProductSerializer+ end+ end+ end+ end+ end+enddiff --git a/api/app/controllers/spree/api/v2/storefront/wishlists_controller.rb b/api/app/controllers/spree/api/v2/storefront/wishlists_controller.rbnew file mode 100644index 0000000000..c808a6d963--- /dev/null+++ b/api/app/controllers/spree/api/v2/storefront/wishlists_controller.rb@@ -0,0 +1,81 @@+module Spree+ module Api+ module V2+ module Storefront+ class WishlistsController < ::Spree::Api::V2::BaseController+ include Spree::Api::V2::CollectionOptionsHelpers++ before_action :require_spree_current_user++ def index+ spree_authorize! :index, Spree::Wishlist+ wishlists = spree_current_user.wishlists.page(params[:page]).per(params[:per_page])+ render_serialized_payload { serialize_collection(wishlists) }+ end++ def create+ spree_authorize! :create, Spree::Wishlist+ wishlist = Spree::Wishlist.new( wishlist_attributes )+ wishlist.user = spree_current_user+ wishlist.save++ if wishlist.persisted?+ render_serialized_payload { serialize_resource(wishlist) }+ else+ render_error_payload(wishlist.errors.full_messages.to_sentence)+ end+ end++ def show+ render_serialized_payload { serialize_resource(resource) }+ end++ def update+ authorize! :update, resource+ resource.update wishlist_attributes++ if resource.errors.empty?+ render_serialized_payload { serialize_resource(resource) }+ else+ render_error_payload(resource.errors.full_messages.to_sentence)+ end+ end++ def destroy+ authorize! :destroy, resource+ if resource.destroy+ render_serialized_payload { serialize_resource(resource) }+ else+ render_error_payload('Something went wrong')+ end+ end++ def default+ spree_authorize! :create, Spree::Wishlist+ wishlist = spree_current_user.wishlist++ render_serialized_payload { serialize_resource(wishlist) }+ end++ private++ def wishlist_attributes+ params.require(:wishlist).permit(:name, :is_default, :is_private)+ end++ def resource+ @resource ||= Spree::Wishlist.find_by!(access_hash: params[:id])+ end++ def resource_serializer+ ::Spree::V2::Storefront::WishlistSerializer+ end++ def collection_serializer+ ::Spree::V2::Storefront::WishlistSerializer+ end+ end+ end+ end+ end+enddiff --git a/api/app/serializers/spree/v2/storefront/wished_product_serializer.rb b/api/app/serializers/spree/v2/storefront/wished_product_serializer.rbnew file mode 100644index 0000000000..7487054fd8--- /dev/null+++ b/api/app/serializers/spree/v2/storefront/wished_product_serializer.rb@@ -0,0 +1,14 @@+module Spree+ module V2+ module Storefront+ class WishedProductSerializer < BaseSerializer+ set_type :wished_product++ attributes :remark, :quantity, :total, :display_total++ belongs_to :variant+ belongs_to :wishlist, serializer: ::Spree::V2::Storefront::WishlistSerializer+ end+ end+ end+enddiff --git a/api/app/serializers/spree/v2/storefront/wishlist_serializer.rb b/api/app/serializers/spree/v2/storefront/wishlist_serializer.rbnew file mode 100644index 0000000000..8288a1c4d4--- /dev/null+++ b/api/app/serializers/spree/v2/storefront/wishlist_serializer.rb@@ -0,0 +1,14 @@+module Spree+ module V2+ module Storefront+ class WishlistSerializer < BaseSerializer+ set_type :wishlist++ attributes :access_hash, :name, :is_private, :is_default++ belongs_to :user+ has_many :wished_products+ end+ end+ end+enddiff --git a/api/config/routes.rb b/api/config/routes.rbindex e69ddb1bb7..e0002e5313 100644--- a/api/config/routes.rb+++ b/api/config/routes.rb@@ -166,6 +166,11 @@ Spree::Core::Engine.add_routes doresources :menus, only: %i[index show]resources :cms_pages, only: %i[index show]++ resources :wishlists do+ get 'default', on: :collection+ resources :wished_products, only: [:create, :update, :destroy]+ endendnamespace :platform dodiff --git a/core/app/models/concerns/spree/user_methods.rb b/core/app/models/concerns/spree/user_methods.rbindex 58796b1646..513e50edae 100644--- a/core/app/models/concerns/spree/user_methods.rb+++ b/core/app/models/concerns/spree/user_methods.rb@@ -25,6 +25,8 @@ module Spreebelongs_to :ship_address, class_name: 'Spree::Address', optional: truebelongs_to :bill_address, class_name: 'Spree::Address', optional: true+ has_many :wishlists, class_name: 'Spree::Wishlist'+self.whitelisted_ransackable_associations = %w[bill_address ship_address addresses]self.whitelisted_ransackable_attributes = %w[id email]@@ -66,6 +68,14 @@ module Spreeendend+ def wishlist(current_store_id)+ default_wishlist = wishlists.where(is_default: true).first+ default_wishlist ||= wishlists.first+ default_wishlist ||= wishlists.create(name: Spree.t(:default_wishlist_name), is_default: true, store_id: current_store_id)+ default_wishlist.update_attribute(:is_default, true) unless default_wishlist.is_default?+ default_wishlist+ end+privatedef check_completed_ordersdiff --git a/core/app/models/spree/store.rb b/core/app/models/spree/store.rbindex 02889e3cac..b4b0e2a0a8 100644--- a/core/app/models/spree/store.rb+++ b/core/app/models/spree/store.rb@@ -36,6 +36,8 @@ module Spreehas_many :store_promotions, class_name: 'Spree::StorePromotion'has_many :promotions, through: :store_promotions, class_name: 'Spree::Promotion'+ has_many :wishlists, class_name: 'Spree::Wishlist'+belongs_to :default_country, class_name: 'Spree::Country'belongs_to :checkout_zone, class_name: 'Spree::Zone'diff --git a/core/app/models/spree/variant.rb b/core/app/models/spree/variant.rbindex dcdb8d8fc5..672243ed9e 100644--- a/core/app/models/spree/variant.rb+++ b/core/app/models/spree/variant.rb@@ -42,6 +42,8 @@ module Spreedependent: :destroy,inverse_of: :variant+ has_many :wished_products, dependent: :destroy+before_validation :set_cost_currencyvalidate :check_pricediff --git a/core/app/models/spree/wished_product.rb b/core/app/models/spree/wished_product.rbnew file mode 100644index 0000000000..425395a571--- /dev/null+++ b/core/app/models/spree/wished_product.rb@@ -0,0 +1,16 @@+module Spree+ class WishedProduct < Spree::Base+ belongs_to :variant+ belongs_to :wishlist++ has_one :product, through: :variant++ def total+ quantity * (variant.price || 0)+ end++ def display_total+ Spree::Money.new(total)+ end+ end+enddiff --git a/core/app/models/spree/wishlist.rb b/core/app/models/spree/wishlist.rbnew file mode 100644index 0000000000..89d0a6edd6--- /dev/null+++ b/core/app/models/spree/wishlist.rb@@ -0,0 +1,40 @@+module Spree+ class Wishlist < Spree::Base+ include SingleStoreResource++ has_secure_token++ belongs_to :user, class_name: Spree.user_class.to_s+ belongs_to :store, touch: true++ has_many :wished_products, dependent: :destroy++ validates :name, presence: true++ def include?(variant_id)+ wished_products.map(&:variant_id).include? variant_id.to_i+ end++ def to_param+ token+ end++ def self.get_by_param(param)+ find_by_token(param)+ end++ def can_be_read_by?(user)+ !is_private? || user == self.user+ end++ def is_default=(value)+ self[:is_default] = value+ return unless is_default?+ Spree::Wishlist.where(is_default: true, user_id: user_id).where.not(id: id).update_all(is_default: false)+ end++ def is_public?+ !self.is_private?+ end+ end+enddiff --git a/core/config/locales/en.yml b/core/config/locales/en.ymlindex 9d45513d29..748619b658 100644--- a/core/config/locales/en.yml+++ b/core/config/locales/en.yml@@ -921,6 +921,7 @@ en:default_refund_amount: Default Refund Amountdefault_tax: Default Taxdefault_tax_zone: Default Tax Zone+ default_wishlist_name: Wishlistdelete: Deletedeleted: Deleteddelete_from_taxon: Delete From Taxondiff --git a/core/db/migrate/20210902110757_create_spree_wishlists.rb b/core/db/migrate/20210902110757_create_spree_wishlists.rbindex 6750e278bf..3cb68d9fdf 100644--- a/core/db/migrate/20210902110757_create_spree_wishlists.rb+++ b/core/db/migrate/20210902110757_create_spree_wishlists.rb@@ -5,13 +5,14 @@ class CreateSpreeWishlists < ActiveRecord::Migration[5.2]t.belongs_to :storet.column :name, :string- t.column :token, :string+ t.column :token, :string, null: falset.column :is_private, :boolean, default: true, null: falset.column :is_default, :boolean, default: false, null: falset.timestampsend+ add_index :spree_wishlists, :token, unique: trueadd_index :spree_wishlists, [:user_id, :is_default] unless index_exists?(:spree_wishlists, [:user_id, :is_default])endenddiff --git a/core/lib/spree/permitted_attributes.rb b/core/lib/spree/permitted_attributes.rbindex 83e4d7cd27..cbfb082636 100644--- a/core/lib/spree/permitted_attributes.rb+++ b/core/lib/spree/permitted_attributes.rb@@ -29,7 +29,9 @@ module Spree:user_attributes,:variant_attributes,:cms_page_attributes,- :cms_section_attributes+ :cms_section_attributes,+ :wishlist_attributes,+ :wished_product_attributes]mattr_reader *ATTRIBUTES@@ -140,5 +142,9 @@ module Spree:weight, :height, :width, :depth, :sku, :cost_currency,options: [:name, :value], option_value_ids: []]++ @@wishlist_attributes = [ :name, :is_default, :is_private ]++ @@wished_product_attributes = [ :variant_id, :remark, :quantity ]endenddiff --git a/frontend/app/assets/javascripts/spree/frontend.js b/frontend/app/assets/javascripts/spree/frontend.jsindex de78e91688..f0159017e4 100644--- a/frontend/app/assets/javascripts/spree/frontend.js+++ b/frontend/app/assets/javascripts/spree/frontend.js@@ -31,6 +31,7 @@//= require spree/frontend/views/spree/products/index//= require spree/frontend/views/spree/products/modal_carousel//= require spree/frontend/views/spree/products/price_filters+//= require spree/frontend/views/spree/products/wishlist//= require spree/frontend/views/spree/shared/carousel//= require spree/frontend/views/spree/shared/carousel/single//= require spree/frontend/views/spree/shared/carousel/swipesdiff --git a/frontend/app/assets/javascripts/spree/frontend/views/spree/products/wishlist.es6 b/frontend/app/assets/javascripts/spree/frontend/views/spree/products/wishlist.es6new file mode 100644index 0000000000..30af766b44--- /dev/null+++ b/frontend/app/assets/javascripts/spree/frontend/views/spree/products/wishlist.es6@@ -0,0 +1,22 @@+(function() {+ Spree.ready(function($) {+ $('#new_wished_product').on('submit', function() {+ const selectedVariantId = $('#add-to-cart-form input[name="variant_id"]').val()++ if (selectedVariantId != null) {+ $('#wished_product_variant_id').val(selectedVariantId)+ }+ const cartQuantity = $('#quantity').val()+ if (cartQuantity) {+ return $('#wished_product_quantity').val(cartQuantity)+ }+ })+ $('form#change_wishlist_accessibility').on('submit', function() {+ $.post($(this).prop('action'), $(this).serialize(), null, 'script')+ return false+ })+ return $('form#change_wishlist_accessibility input[type=radio]').on('click', function() {+ return $(this).parent().submit()+ })+ })+}).call(this)diff --git a/frontend/app/controllers/spree/wished_products_controller.rb b/frontend/app/controllers/spree/wished_products_controller.rbnew file mode 100644index 0000000000..37b69616af--- /dev/null+++ b/frontend/app/controllers/spree/wished_products_controller.rb@@ -0,0 +1,58 @@+module Spree+ class WishedProductsController < Spree::StoreController+ include Spree::Core::ControllerHelpers::Order++ before_action :load_default_wishlist, only: [:create]++ respond_to :html++ def create+ @wished_product = Spree::WishedProduct.new(wished_product_attributes)++ if @default_wishlist.include? params[:wished_product][:variant_id]+ @wished_product = @default_wishlist.wished_products.detect { |wp| wp.variant_id == params[:wished_product][:variant_id].to_i }+ else+ @wished_product.wishlist = spree_current_user.wishlist(current_store.id)+ @wished_product.save+ end++ respond_with(@wished_product) do |format|+ format.html { redirect_to wishlist_url(@default_wishlist) }+ end+ end++ def update+ @wished_product = Spree::WishedProduct.find(params[:id])+ @wished_product.update(wished_product_attributes)++ respond_with(@wished_product) do |format|+ format.html { redirect_to wishlist_url(@wished_product.wishlist) }+ end+ end++ def destroy+ @wished_product = Spree::WishedProduct.find(params[:id])+ @wished_product.destroy++ respond_with(@wished_product) do |format|+ format.html { redirect_to wishlist_url(@wished_product.wishlist), status: :see_other }+ end+ end++ private++ def load_default_wishlist+ @default_wishlist = spree_current_user.wishlists.find_by(store_id: current_store.id, is_default: true)++ if @default_wishlist.nil?+ @default_wishlist = spree_current_user.wishlist(current_store.id)++ @default_wishlist+ end+ end++ def wished_product_attributes+ params.require(:wished_product).permit(:variant_id, :remark, :quantity)+ end+ end+enddiff --git a/frontend/app/controllers/spree/wishlists_controller.rb b/frontend/app/controllers/spree/wishlists_controller.rbnew file mode 100644index 0000000000..b45fafcfc6--- /dev/null+++ b/frontend/app/controllers/spree/wishlists_controller.rb@@ -0,0 +1,74 @@+module Spree+ class WishlistsController < Spree::StoreController+ include Spree::FrontendHelper+ include Spree::CacheHelper++ include Spree::Core::ControllerHelpers::Order++ helper 'spree/products'++ before_action :load_wishlist, only: [:destroy, :show, :update, :edit]++ respond_to :html++ def new+ @wishlist = Spree::Wishlist.new++ ensure_current_store(@wishlist)+ respond_with(@wishlist)+ end++ def index+ @wishlists = spree_current_user.wishlists+ respond_with(@wishlist)+ end++ def edit+ respond_with(@wishlist)+ end++ def update+ @wishlist.update wishlist_attributes+ respond_with(@wishlist)+ end++ def show+ respond_with(@wishlist)+ end++ def default+ @wishlist = spree_current_user.wishlist+ respond_with(@wishlist) do |format|+ format.html { render :show }+ end+ end++ def create+ @wishlist = Spree::Wishlist.new wishlist_attributes+ @wishlist.user = spree_current_user++ ensure_current_store(@wishlist)++ @wishlist.save++ respond_with(@wishlist)+ end++ def destroy+ @wishlist.destroy+ respond_with(@wishlist) do |format|+ format.html { redirect_to account_path }+ end+ end++ private++ def wishlist_attributes+ params.require(:wishlist).permit(:name, :is_default, :is_private, :store_id, :store)+ end++ def load_wishlist+ @wishlist = current_store.wishlists.find_by(token: params[:id])+ end+ end+enddiff --git a/frontend/app/views/spree/products/show.html.erb b/frontend/app/views/spree/products/show.html.erbindex e914bfd499..8238152dd4 100644--- a/frontend/app/views/spree/products/show.html.erb+++ b/frontend/app/views/spree/products/show.html.erb@@ -15,6 +15,18 @@</h1><div id="cart-form" data-hook="cart_form"><%= render 'cart_form', variant_change_identifier: 'productCarousel' %>++ <% if spree_current_user %>+ <div id="wishlist-form">+ <%= form_for Spree::WishedProduct.new do |f| %>+ <%= f.hidden_field :variant_id, value: @product.master.id %>+ <%= f.hidden_field :quantity %>+ <button type="submit" class="btn btn-outline-primary w-100 font-weight-bold text-uppercase mt-2">+ <%= Spree.t(:add_to_wishlist) %>+ </button>+ <% end %>+ </div>+ <% end %></div></div></div>diff --git a/frontend/app/views/spree/users/show.html.erb b/frontend/app/views/spree/users/show.html.erbindex 9fec0545a2..f519d3b835 100755--- a/frontend/app/views/spree/users/show.html.erb+++ b/frontend/app/views/spree/users/show.html.erb@@ -78,6 +78,16 @@<% end %><br></div>++ <h3><%= Spree.t(:my_wishlists) %></h3>+ <ul>+ <% @user.wishlists.each do |wl| %>+ <% if !wl.is_private? || @user == spree_current_user %>+ <li><%= link_to wl.name, wl %></li>+ <% end -%>+ <% end -%>+ </ul>+<div id="delete-address-popup" class="delete-address-popup-dropdown hide-on-esc"><%= render 'spree/shared/delete_address_popup' %></div>diff --git a/frontend/app/views/spree/wishlists/_accessibility.html.erb b/frontend/app/views/spree/wishlists/_accessibility.html.erbnew file mode 100755index 0000000000..c9a9503c36--- /dev/null+++ b/frontend/app/views/spree/wishlists/_accessibility.html.erb@@ -0,0 +1,4 @@+<%= form_for @wishlist, html: { class: 'ajax_form', id: 'change_wishlist_accessibility' } do |f| %>+ <%= f.radio_button :is_private, true %> <%= Spree.t(:private) %>+ <%= f.radio_button :is_private, false %> <%= Spree.t(:public) %>+<% end -%>diff --git a/frontend/app/views/spree/wishlists/_mail_to_friend.text.erb b/frontend/app/views/spree/wishlists/_mail_to_friend.text.erbnew file mode 100644index 0000000000..aa782d1bef--- /dev/null+++ b/frontend/app/views/spree/wishlists/_mail_to_friend.text.erb@@ -0,0 +1,14 @@+<%= mail.recipient_name %>,++<%= Spree.t(:take_a_look_at_my_wishlist) %>++ * <%= wishlist.name %>++<% unless mail.message.blank? -%>+<%= mail.message %>+<% end -%>++<%= mail.sender_name %>++<%= Spree.t(:click_link_to_view_wishlist, name: wishlist.name) %>+<%= wishlist_url(wishlist) %>diff --git a/frontend/app/views/spree/wishlists/edit.html.erb b/frontend/app/views/spree/wishlists/edit.html.erbnew file mode 100755index 0000000000..e3fdd30968--- /dev/null+++ b/frontend/app/views/spree/wishlists/edit.html.erb@@ -0,0 +1,9 @@+<h1 class="row"><%= Spree.t(:editing_wishlist) %></h1>+<%= form_for @wishlist do |f| %>+ <p><%= f.label :name, Spree.t(:name) %>: <%= f.text_field :name %></p>+ <p><%= f.check_box :is_private %> <%= f.label :is_private, Spree.t(:is_private) %></p>+ <p><%= f.check_box :is_default %> <%= f.label :is_default, Spree.t(:is_default) %></p>+ <%= f.submit Spree.t(:update) %>+ <%= Spree.t(:or) %>+ <%= link_to Spree.t(:delete_wishlist), @wishlist, method: :delete, data: { confirm: Spree.t(:are_you_sure_wishlist) }, class: 'button' %>+<% end -%>diff --git a/frontend/app/views/spree/wishlists/index.html.erb b/frontend/app/views/spree/wishlists/index.html.erbnew file mode 100755index 0000000000..45eed87f3e--- /dev/null+++ b/frontend/app/views/spree/wishlists/index.html.erb@@ -0,0 +1,8 @@+<h1 class="row"><%= Spree.t(:wishlists) %></h1>+<%= content_tag :ul do %>+ <% @wishlists.each do |wishlist| %>+ <%= content_tag :li do %>+ <%= link_to(wishlist.name, wishlist) %> - <%= wishlist.is_private ? Spree.t(:private) : Spree.t(:public) %>+ <% end %>+ <% end %>+<% end %>diff --git a/frontend/app/views/spree/wishlists/new.html.erb b/frontend/app/views/spree/wishlists/new.html.erbnew file mode 100755index 0000000000..3dd50ba81b--- /dev/null+++ b/frontend/app/views/spree/wishlists/new.html.erb@@ -0,0 +1,6 @@+<h1><%= Spree.t(:creating_wishlist) %></h1>+<%= form_for @wishlist do |f| %>+ <p><%= f.label :name, Spree.t(:name) %>: <%= f.text_field :name %></p>+ <p><%= f.check_box :is_private %> <%= f.label :is_private, Spree.t(:is_private) %></p>+ <%= f.submit Spree.t(:create) %>+<% end -%>diff --git a/frontend/app/views/spree/wishlists/show.html.erb b/frontend/app/views/spree/wishlists/show.html.erbnew file mode 100755index 0000000000..c13f85f511--- /dev/null+++ b/frontend/app/views/spree/wishlists/show.html.erb@@ -0,0 +1,100 @@+<div class="container">+ <div id="wishlist_header">++ <% if @wishlist&.user == spree_current_user %>+ <h1><%= @wishlist.name %></h1>+ <div id="manage_wishlist_links">+ <%= link_to Spree.t(:edit_wishlist), edit_wishlist_path(@wishlist), class: 'button' %>+ </div>+ <div><%= render partial: 'accessibility' %></div>+ <% end %>+ </div>+ <table id="wishlist" class="table table-bordered table-hover">+ <thead>+ <tr>+ <% if @wishlist&.user == spree_current_user %>+ <th><%= Spree.t(:wishlist_actions) %></th>+ <% end %>+ <th><%= Spree.t(:item_view) %></th>+ <th><%= Spree.t(:item_description) %></th>+ <th><%= Spree.t(:availability) %></th>+ <th><%= Spree.t(:date_added) %></th>+ <th><%= Spree.t(:price) %></th>+ <th><%= Spree.t(:quantity) %></th>+ <th><%= Spree.t(:total) %></th>+ </tr>+ </thead>+ <tbody id="line_items">+ <% if @wishlist&.wished_products.size > 0 %>+ <% @wishlist.wished_products.each do |wish|+ variant = wish.variant+ product = variant.product %>+ <tr class="<%= cycle('', 'alt') %>">+ <% if @wishlist.user == spree_current_user %>+ <td>+ <p><%= link_to Spree.t(:remove_from_wishlist), wish, method: :delete, class: 'btn btn-danger' %></p>+ <%= form_for :order, url: 'populate_orders_url' do |f| %>+ <%= hidden_field_tag 'variant_id', variant.id, size: 3 %>+ <%= Spree.t(:quantity) %>+ <%= number_field_tag 'quantity', wish.quantity, size: 3 %>+ <%= link_to Spree.t(:add_to_cart), '#', onclick: '$(this).parent().submit(); return false;', class: 'btn btn-success' %>+ <% end %>+ <% if spree_current_user.wishlists.count > 1 %>+ <%= Spree.t(:move_to_another_wishlist) %>:+ <%= form_for wish do |f| %>+ <%= f.select :wishlist_id, spree_current_user.wishlists.map{|wl| [wl.name, wl.id]} %>+ <%= f.submit Spree.t(:move), class: 'btn btn-default' %>+ <% end %>+ <% end %>+ <br />+ </td>+ <% end -%>+ <td>+ <% if variant.images.length == 0 %>+ <%= small_image(variant.product) %>+ <% else %>+ <%= image_tag variant.images.first.attachment.url(:small) %>+ <% end %>+ </td>+ <td>+ <h4><%= link_to product.name, product %></h4>+ <p><%= variant.options_text %></p>+ <%= truncate(strip_tags(product.description), length: 100, omission: '...') %>+ </td>+ <td>+ <%= variant.can_supply? ? Spree.t(:in_stock) : Spree.t(:out_of_stock) %>+ </td>+ <td>+ <%= wish.created_at.strftime '%m/%d/%Y' %>+ </td>+ <td>+ <%= display_price(variant) %>+ </td>+ <td>+ <%= form_for wish do |f| %>+ <%= f.number_field :quantity %>+ <%= f.submit Spree.t('actions.save'), class: 'btn btn-info ' %>+ <% end %>+ </td>+ <td>+ <%= wish.display_total %>+ </td>+ </tr>+ <% end %>+ <% else %>+ <tr>+ <td colspan="6"><%= Spree.t(:your_wishlist_is_empty) %></td>+ </tr>+ <% end %>+ </tbody>+ </table>+ <div class="footer_links" data-hook="wishlist_footer_links">+ <% if @wishlist.user == spree_current_user %>+ <%= link_to Spree.t(:create_new_wishlist), new_wishlist_path, class: 'btn btn-default' %>+ <% end %>+ <%= link_to Spree.t(:continue_shopping), products_path, class: 'btn btn-default' %>+ <% if respond_to?(:email_to_friend_url) %>+ <%= link_to Spree.t('email_to_friend.send_to_friend'), email_to_friend_url('wishlist', @wishlist), class: 'btn btn-default' %>+ <% end %>+ </div>+</div>diff --git a/frontend/config/locales/en.yml b/frontend/config/locales/en.ymlnew file mode 100644index 0000000000..09f158f7d3--- /dev/null+++ b/frontend/config/locales/en.yml@@ -0,0 +1,32 @@+---+en:+ spree:+ add_to_wishlist: "Add to wishlist"+ are_you_sure_wishlist: "Are you sure that you want to delete this wishlist?"+ availability: "Availability"+ create_new_wishlist: "Create new wishlist"+ creating_wishlist: "Creating wishlist"+ date_added: "Date added"+ delete_wishlist: "Delete wishlist"+ edit_wishlist: "Edit wishlist"+ editing_wishlist: "Editing wishlist"+ in_stock: "In stock"+ is_default: "is default"+ is_private: "is private"+ item_view: "View"+ move: "Move"+ move_to_another_wishlist: "Move to another wishlist"+ my_wishlists: "My wishlists"+ private_wishlist: "Private wishlist"+ private: "Private"+ public_wishlist: "Public wishlist"+ public: "Public"+ remove_from_wishlist: "Remove from wishlist"+ wishlist_actions: "Actions"+ your_wishlist_is_empty: "Your wishlist is empty"+ update_quantity: "Update quantity"+ item_added_to_wishlist: "Item added to wishlist"+ take_a_look_at_my_wishlist: "Please, take a look at my wishlist:"+ click_link_to_view_wishlist: "Click the link below to view the %{name} page."+ quantity: "Quantity"+ total: "Total"diff --git a/frontend/config/routes.rb b/frontend/config/routes.rbindex 614d32fbb7..41a9ecfc31 100644--- a/frontend/config/routes.rb+++ b/frontend/config/routes.rb@@ -18,6 +18,11 @@ Spree::Core::Engine.add_routes doresources :addresses, except: [:index, :show]+ resources :wishlists+ resources :wished_products, only: [:create, :update, :destroy]++ get '/wishlist', to: "wishlists#default", as: :default_wishlist+get '/cart', to: 'orders#edit', as: :cartpatch '/cart', to: 'orders#update', as: :update_cartput '/cart/empty', to: 'orders#empty', as: :empty_cart