Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Code improvements.

Matthew Kennedy4198d2f72e27
diff --git a/api/app/controllers/spree/api/v2/storefront/wished_variants_controller.rb b/api/app/controllers/spree/api/v2/storefront/wished_variants_controller.rb
index df27ea8f9b..d04e1f516a 100644
--- a/api/app/controllers/spree/api/v2/storefront/wished_variants_controller.rb
+++ b/api/app/controllers/spree/api/v2/storefront/wished_variants_controller.rb
@@ -10,7 +10,7 @@ module Spree
wished_variant = Spree::WishedVariant.new(wished_variant_attributes)
if wishlist.include? params[:wished_variant][:variant_id]
- wished_variant = wishlist.wished_variants.detect { |wp| wp.variant_id == params[:wished_variant][:variant_id].to_i }
+ wished_variant = wishlist.wished_variants.detect { |item| item.variant_id.to_s == params[:wished_product][:variant_id] }
else
wished_variant.wishlist = wishlist
wished_variant.save
diff --git a/core/app/models/spree/wishlist.rb b/core/app/models/spree/wishlist.rb
index 2746c8a420..d94236163b 100644
--- a/core/app/models/spree/wishlist.rb
+++ b/core/app/models/spree/wishlist.rb
@@ -4,8 +4,8 @@ module Spree
has_secure_token
- belongs_to :user, class_name: Spree.user_class.to_s
- belongs_to :store, class_name: 'Spree::Store', touch: true
+ belongs_to :user, class_name: Spree.user_class.to_s, touch: true
+ belongs_to :store, class_name: 'Spree::Store'
has_many :wished_variants, class_name: 'Spree::WishedVariant', dependent: :destroy
@@ -21,7 +21,7 @@ module Spree
end
def self.get_by_param(param)
- find_by_token(param)
+ find_by(token: param)
end
def can_be_read_by?(user)