Coder Social home page Coder Social logo

spree-contrib / spree_multi_vendor Goto Github PK

View Code? Open in Web Editor NEW
139.0 25.0 129.0 444 KB

Spree marketplace extension. Create your own marketplace on top of Spree Commerce

Home Page: https://getvendo.com

License: BSD 3-Clause "New" or "Revised" License

Ruby 94.49% HTML 5.51%
marketplace online-marketplace spree-commerce

spree_multi_vendor's Introduction

Spree Multi Vendor

This is a spree multi vendor marketplace extension. It's a great starting point if you're building a marketplace on top of Spree. Our goal was flexibility to allow you to tweak it to your needs.

Developed by

Vendo

All-in-one platform for all your multi-vendor Marketplace needs. Get started

Open source vs Vendo

If you need a product that has all of the features out of the box, such us supplier onboarding, Stripe connect payment splitting and payouts, and don't require any custom development - we recommend using Vendo.

feature open source vendo
basic vendorization ✔️ ✔️
supplier onboarding ✔️
supplier dashboard ✔️
supplier management ✔️
supplier product curation ✔️
automatic payment splitting ✔️
automatic payouts ✔️
Afterpay / klarna / apple pay ✔️
shopify / bigcommerce / woocommerce integration ✔️
USPS, UPS, FedEx, DHL, and more ✔️
bulk upload / import of products from CSV and XSLX ✔️
bulk export of orders, shipments and more ✔️

Installation

  1. Add this extension to your Gemfile with this line:

    gem 'spree_multi_vendor'
  2. Install the gem using Bundler:

    bundle install
  3. Copy & run migrations

    bundle exec rails g spree_multi_vendor:install
  4. Restart your server

    If your server was running, restart it so that it can find the assets properly.

  5. Optionally you can also create sample Vendor by running:

    bundle exec rake spree_multi_vendor:sample:create

Upgrading

  1. Fetch new database migrations:

    bundle exec rake railties:install:migrations FROM=spree_multi_vendor
  2. Run migrations

    bundle exec rails db:migrate

Configuration

To change which models should be vendorized, in your Spree initializer (config/initializers/spree.rb) add:

SpreeMultiVendor::Config[:vendorized_models] = %w[product variant stock_location shipping_method other_model]

This will lookup for Spree::OtherModel class. To add vendor_id column to that model run:

bundle exec rails g migration AddVendorToSpreeOtherModels vendor:references

API endpoints

Spree Multi Vendor adds new API v2 endpoints:

  1. GET Display Vendor information endpoint

    /api/v2/storefront/vendors/<vendor_slug>
    

    eg. /api/v2/storefront/vendors/test-vendor

    you can also include Vendor image and/or Products in that call:

    /api/v2/storefront/vendors/test-vendor?include=image,products

  2. GET Returns a list of Vendors

    /api/v2/storefront/vendors
    

    you can also include Vendor image and/or Products in that call:

    /api/v2/storefront/vendors?include=image,products

And modfies existing:

  1. GET Filtering Products by Vendor ID(s):

    /api/v2/storefront/products?filter[vendor_ids]=1,2,3
    
  2. GET Include Vendor information in Cart endpoint:

    /api/v2/storefront/cart?include=vendors,vendor_totals
    

Email previews

Spree offers emails preview generator for development purposes. To generate them, use command:

bundle exec rails g spree_multi_vendor:mailers_preview

After that, start rails server locally and go to: localhost:3000/rails/mailers

(it requires seeded development database in order to work properly)

Testing

First bundle your dependencies, then run rake. rake will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using rake test_app.

bundle
bundle exec rake

When testing your applications integration with this extension you may use it's factories. Simply add this require statement to your spec_helper:

require 'spree_multi_vendor/factories'

Contributing

If you'd like to contribute, please take a look at the instructions for installing dependencies and crafting a good pull request.

License

Spree Multi-Vendor is copyright © 2017-2023 Vendo Connect Inc. It is free software, and may be redistributed under the terms specified in the LICENCE file.

About Vendo

Vendo is a great fit for marketplaces of all sizes - either with its own fulfillment and multiple warehouses or in a dropshipping model. Vendo automates everything from vendor onboarding, accepting buyer payments in over 135 currencies, to supplier payouts in 50 countries.

Vendo ensures excellent buyer experience with smooth product discovery and search, many payment methods, and optimal shipping cost calculation. Vendo keeps suppliers happy with easy onboarding, automated product sync using their preferred method, and easy payouts.

Get started

spree_multi_vendor's People

Contributors

aleksandrakaminska avatar aplegatt avatar brayvasq avatar chhlga avatar chinoxchen avatar chrislaai avatar coolprobn avatar damianlegawiec avatar dependabot-preview[bot] avatar drkpkg avatar hoshinotsuyoshi avatar joatere avatar juansegimenez avatar kacpermekarski avatar kgorazd avatar kushniryb avatar mohammedamarnah avatar mradfaber avatar omairrazam avatar pmilewski avatar poudelprakash avatar pszyszkaspark avatar rafalcymerys avatar ronzalo avatar stefnnn avatar szymoniwacz avatar tomdonarski avatar vanessayuenn avatar vasundhara-digitalairtech avatar z4ppy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spree_multi_vendor's Issues

Cannot checkout a product if the product belongs to a vendor.

I try the store flow and the product cannot pass the delivery into the checkout cart flow.

Steps:

  • Create a product and made it visible into the store with stock, assign it to a vendor
  • Go to the store and select the product to checkout
  • Proceed the checkout and is there when it fails.

I configure the zones and the stock locations, payment methods and delivery options are ok with products that doesn't have a vendor assigned.

I tested again, it's the vendor location itself. If I create the product without vendor and later assign a vendor, add stock in the new location it will works, but it never takes the product stock from the vendor stock location, it takes from the default stock location.

Video about the issue:
https://drive.google.com/file/d/1G4d1vRygTB4ffd0PgcDz1e1YRrryhXa6/view?usp=sharing

SpreeMultiVendor::Config not work!!!

According to documentation I added following code to initializers/spree.rb

SpreeMultiVendor::Config[:vendorized_models] = %w[product variant]

But it's not working. I see orders, products, vendor settings and configs.

Here is the my environments:

4 ruby '3.0.0'
5                                                                                  
6 # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
7 gem 'rails', '~> 6.1.3'
8 # Use postgresql as the database for Active Record                               
9 gem 'pg', '~> 1.1'
10 # Use Puma as the app server                                                    
11 gem 'puma', '~> 5.0'
12 # Use SCSS for stylesheets                                                      
13 gem 'sass-rails', '>= 6'                                                        
14 # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker 15 gem 'webpacker', '~> 5.0'
16 # Turbolinks makes navigating your web application faster. Read more: https://g    ithub.com/turbolinks/turbolinks
17 gem 'turbolinks', '~> 5'
18 # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
19 gem 'jbuilder', '~> 2.7'
20 # Use Redis adapter to run Action Cable in production                           
21 # gem 'redis', '~> 4.0'
22 # Use Active Model has_secure_password
23 # gem 'bcrypt', '~> 3.1.7'                                                      
24
25 # Use Active Storage variant                                                    
26 # gem 'image_processing', '~> 1.2'
27                                                                                 
28 gem 'spree', '~> 4.2.0'                                                         
29 gem 'spree_auth_devise', '~> 4.3'
30 gem 'spree_gateway', '~> 3.9'
31 gem 'spree_i18n', '~> 5.0'
32
33 gem 'spree_analytics_trackers', '~> 2.0'                                        
34 gem 'spree_social', github: 'spree-contrib/spree_social'                        
35 gem 'spree_multi_vendor'

State name conflict

Can we change the name of the vendor "state" to "status"? State is a bit confusing for us since are adding address, city, state, zipcode, etc as some extra fields to the vendor. Status seems like a more descriptive word and less likely to conflict with anyone's additional fields.

OrderCommissions are not created when using `spree_gateway` 3.9+

Context

When used in combination with spree_gateway ( https://github.com/spree/spree_gateway ) version 3.9+ , you may encounter the problem that commissions are not created depending on the order in which the modules are loaded.

I'm using spree_multi_vendor and when I updated spree_gateway to 3.8-> 3.9 (October update) I ran into such a problem.

Because spree_gateway 3.9.0 introduces Spree::OrderDecorator and its method .prepended ( https://github.com/spree/spree_gateway/blob/v3.9.0/app/models/spree/order_decorator.rb#L3-L11 ) and spree_multi_vendor has already that name class and method (

def self.prepended(base)
base.has_many :commissions, class_name: 'Spree::OrderCommission'
base.state_machine.after_transition to: :complete, do: :generate_order_commissions
base.state_machine.after_transition to: :complete, do: :send_notification_mails_to_vendors
end
) , module name duplication occurs.

Regarding the order in which the modules are loaded, I don't know how to do it and what kind of problems will occur.
But I can show you a workaround and how to reproduce the problem.

I wrote a Pull Request for a workaround, so take a look( TBD #147 ).

Expected Behavior

OrderCommission are created.

Actual Behavior

OrderCommission are not created.

Possible Fix

  • PullRequest: ( TBD #147 )

Or

  • Use spree_gateway 3.8-

Steps to Reproduce

Reproducing 1.

  1. Install spree_gateway version 3.9.2 (latest version)
  2. Install spree_multi_vendor latest version.
  3. Purchase product which has vendor_id.
  4. The order does not have any order_commissions.

Reproducing 2.

In this repo(spree_multi_vendor),

  • $ git checkout master
  • $ rm -rf spec/dummy
  • $ bundle exec rake test_app
  • Add line gem 'spree_gateway', '3.9.2' to ./Gemfile before gemspec line.
--- a/Gemfile
+++ b/Gemfile
@@ -4,4 +4,6 @@ gem 'spree', github: 'spree/spree', branch: 'master'
 gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
 gem 'rails-controller-testing'

+gem 'spree_gateway', '3.9.0'
+
 gemspec
  • $ bundle install
  • $ bundle exec rspec spec/models/spree/order_spec.rb
(..snip..)
Failures:

  1) Spree::Order complete with spree_multi_vendor generates commission records
     Failure/Error:
       expect do
         order.next!
         order.reload
       end.to change { Spree::OrderCommission.count }.by(2).and change { vendor.commissions.count }.by(1)
                                                           .and change { vendor_2.commissions.count }.by(1)

          expected result to have changed by 2, but was changed by 0

       ...and:

             expected result to have changed by 1, but was changed by 0

          ...and:

             expected `vendor_2.commissions.count` to have changed by 1, but was changed by 0

(..snip..)

Finished in 25.37 seconds (files took 6.19 seconds to load)
79 examples, 1 failure

Failed examples:

rspec ./spec/models/spree/order_spec.rb:24 # Spree::Order complete with spree_multi_vendor generates commission records

Randomized with seed 45239

(..snip..)

When placing an order, generate_order_commissions is run twice, and it fails the second time (already existing record)

For some reason, after placing an order, this:

`
order.vendor_list.each do |vendor|
amount = if vendor.commission_rate.zero?
0.0
else
order.vendor_pre_tax_item_amount(vendor) * vendor.commission_rate / 100
end

order.commissions.create!(
amount: amount,
vendor_id: vendor.id)
end
`

is executed twice and the create! fails

ActiveRecord::RecordInvalid (Validazione fallita: Vendor is already present):

Stock items creation not adjusted for multi vendor

We need to make 2 adjustments which I think were missed.

  1. variant.rb
    method = create_stock_items
    issue = it loops on all stock locations which don't event belong to given vendor
    expected = only create stock items for respective vendor's stock location

  2. stock_location.rb
    method = create_stock_items
    issue = it loops on all variants of all vendor's.
    expected = only create stock item for respective vendor variants.

Overrall Impact faced:

i faced serious performance issue as number of vendors and products increased on my platform and I was able to find this as reason.

Warnings after installing spree_multi_vendor

/Users/prakash/workspaces/2020/ecom/spree_multi_vendor/app/models/spree/order_decorator.rb:69: warning: already initialized constant Spree::OrderDecorator::METHOD_NAMES
/Users/prakash/workspaces/2020/ecom/spree_multi_vendor/app/models/spree/order_decorator.rb:69: warning: previous definition of METHOD_NAMES was here
/Users/prakash/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/bundler/gems/spree-bc02c8ade3b6/core/lib/spree/i18n.rb:18: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/Users/prakash/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actionview-6.0.3.4/lib/action_view/helpers/translation_helper.rb:60: warning: The called method `translate' is defined here

undefined method `commission_rate' for nil:NilClass

Hello,

i just installed the extension and was testing it but run into this problem at checkout.

NoMethodError in Spree::CheckoutController#update
undefined method `commission_rate' for nil:NilClass
Extracted source (around line #19):

order.line_items.includes(product: :vendor).group_by{ |li| li.product.vendor }.each do |vendor, vendor_line_items|
order.commissions.create(
amount: vendor_line_items.pluck(:pre_tax_amount).sum * vendor.commission_rate / 100,
vendor_id: vendor.id
)
end
Steps i made:

  • I created a user and assigned it to a vendor, the i create a product with that user.
  • With another user, i shopped one product from default user and the product I added in the previous step.
  • i did check out and enter the shipping information.
  • I selected one shipping method for the first item and a different method for the second product.
  • I selected check as the payment method and when I click save and continue I get the error!

Can a vendor have its own gateway payment?

What I am trying to accomplish is to enable vendors have their own payment mechanism (for ex. stripe), set up their own stripe keys, and then the admin tracks the order fees (which is already possible via OrderCommission).

But I don't understand why there is the possibility to track the order commissions without having a personal payment gateway per vendor. So the vendors autonomously manage payments that get to their own payment gateway account, but then the admin bills the vendor monthly, by tracking the order commissions.

Am I missing something?

Package model Decorator

There is a typo in PackageModelDecorator.
(-) if (vendor = stock_location.vendor)
(+) if (vendor == stock_location.vendor)

Forbidden/Unauthorized Routes

In vendor setting, there are links such as "Digital Variants", "Translation". On Order screen other than "Customer" and "Shipment" no route works, it shows "Forbidden" or "Unauthorized".

There errors are only in Vendor Admin Area.

Missing partial spree/order_mailer/_adjustment in Spree::VendorMailer#vendor_notification_email

I am using spree 4.2.0 with multi vendor 2.0.2. I am not sure if this spree/order_mailer/_adjustment partial is the responsibility of spree multi-vendor or spree core, but what I've seen is spree/order_mailer/_adjustment has been remove from spree since Spree 4.
You can see the file here:
https://github.com/spree/spree/blob/3-7-stable/core/app/views/spree/order_mailer/_adjustment.html.erb

The fix should be as simple as using the code from https://github.com/spree/spree/blob/3-7-stable/core/app/views/spree/order_mailer/_adjustment.html.erb in place of render partial in the vendor_notification_email.html.erb.

Doesn't work with spree 4.0.0rc1

When running spree:multi_vendor:install it throws an exception.

Using spree 4.0.0.rc1
Using spree_extension 0.0.9
Using spree_auth_devise 4.0.0.rc2
Using spree_gateway 3.6.1
Using spree_multi_vendor 1.3.0 from https://github.com/spree-contrib/spree_multi_vendor.git (at master@a579251)
electric-sheep:spree_backend timuckun$ bundle exec rails g spree_multi_vendor:install
/Users/timuckun/.rvm/gems/ruby-2.6.3/gems/zeitwerk-2.1.10/lib/zeitwerk/loader/callbacks.rb:17:in `on_file_autoloaded': expected file /Users/timuckun/.rvm/gems/ruby-2.6.3/bundler/gems/spree_multi_vendor-a579251b01ce/app/controllers/spree/admin/resource_controller_decorator.rb to define constant Spree::Admin::ResourceControllerDecorator, but didn't (NameError)
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/zeitwerk-2.1.10/lib/zeitwerk/kernel.rb:17:in `block in require'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/zeitwerk-2.1.10/lib/zeitwerk/kernel.rb:16:in `tap'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/zeitwerk-2.1.10/lib/zeitwerk/kernel.rb:16:in `require'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/spree_auth_devise-4.0.0.rc2/lib/controllers/backend/spree/admin/resource_controller_decorator.rb:1:in `<main>'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/spree_auth_devise-4.0.0.rc2/lib/spree/auth/engine.rb:37:in `block in activate'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/spree_auth_devise-4.0.0.rc2/lib/spree/auth/engine.rb:36:in `glob'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/spree_auth_devise-4.0.0.rc2/lib/spree/auth/engine.rb:36:in `activate'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/callbacks.rb:429:in `instance_exec'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/callbacks.rb:429:in `block in make_lambda'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/callbacks.rb:201:in `block (2 levels) in halting'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/callbacks.rb:607:in `block (2 levels) in default_terminator'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/callbacks.rb:606:in `catch'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/callbacks.rb:606:in `block in default_terminator'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/callbacks.rb:202:in `block in halting'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/callbacks.rb:514:in `block in invoke_before'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/callbacks.rb:514:in `each'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/callbacks.rb:514:in `invoke_before'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/callbacks.rb:134:in `run_callbacks'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/reloader.rb:88:in `prepare!'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/railties-6.0.0/lib/rails/application/finisher.rb:113:in `block in <module:Finisher>'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/railties-6.0.0/lib/rails/initializable.rb:32:in `instance_exec'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/railties-6.0.0/lib/rails/initializable.rb:32:in `run'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/railties-6.0.0/lib/rails/initializable.rb:61:in `block in run_initializers'
        from /Users/timuckun/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
        from /Users/timuckun/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        from /Users/timuckun/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
        from /Users/timuckun/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
        from /Users/timuckun/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/tsort.rb:347:in `each'
        from /Users/timuckun/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/tsort.rb:347:in `call'
electric-sheep:spree_backend timuckun$  from /Users/timuckun/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
        from /Users/timuckun/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
        from /Users/timuckun/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/railties-6.0.0/lib/rails/initializable.rb:60:in `run_initializers'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/railties-6.0.0/lib/rails/application.rb:363:in `initialize!'
        from /Users/timuckun/Documents/dropit/source/tim_experiments/spree_backend/config/environment.rb:5:in `<main>'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/zeitwerk-2.1.10/lib/zeitwerk/kernel.rb:23:in `require'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `block in require'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:291:in `load_dependency'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:106:in `preload'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:157:in `serve'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:145:in `block in run'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:139:in `loop'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:139:in `run'
        from /Users/timuckun/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application/boot.rb:19:in `<top (required)>'
        from /Users/timuckun/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /Users/timuckun/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from -e:1:in `<main>'

Error when click on Properties menu as a vendor

Hi,

When I click on Properties sub-menu of Products menu on Admin side and logged as vendor (not admin user), an error happen:

SyntaxError in Spree::Admin::PropertiesController#index

C:/Ruby25-x64/lib/ruby/gems/2.5.0/bundler/gems/spree_multi_vendor-a579251b01ce/app/views/spree/admin/properties/index.html.erb:75: syntax error, unexpected keyword_end, expecting end-of-input '.freeze; end ^~~

properties_error

I used latest source code from this repo

Here is error log:

Completed 500 Internal Server Error in 463ms (ActiveRecord: 0.8ms)


  
SyntaxError (C:/Ruby25-x64/lib/ruby/gems/2.5.0/bundler/gems/spree_multi_vendor-a579251b01ce/app/views/spree/admin/properties/index.html.erb:75: syntax error, unexpected keyword_end, expecting end-of-input
'.freeze;       end 
                ^~~):
  
C:/Ruby25-x64/lib/ruby/gems/2.5.0/bundler/gems/spree_multi_vendor-a579251b01ce/app/views/spree/admin/properties/index.html.erb:75: syntax error, unexpected keyword_end, expecting end-of-input
'.freeze;       end 
                ^~~
actionview (5.2.3) lib/action_view/template.rb:309:in `module_eval'
actionview (5.2.3) lib/action_view/template.rb:309:in `compile'
actionview (5.2.3) lib/action_view/template.rb:259:in `block (2 levels) in compile!'
activesupport (5.2.3) lib/active_support/notifications.rb:170:in `instrument'
actionview (5.2.3) lib/action_view/template.rb:350:in `instrument'
actionview (5.2.3) lib/action_view/template.rb:258:in `block in compile!'
actionview (5.2.3) lib/action_view/template.rb:246:in `synchronize'
actionview (5.2.3) lib/action_view/template.rb:246:in `compile!'
actionview (5.2.3) lib/action_view/template.rb:158:in `block in render'
activesupport (5.2.3) lib/active_support/notifications.rb:170:in `instrument'
actionview (5.2.3) lib/action_view/template.rb:354:in `instrument_render_template'
actionview (5.2.3) lib/action_view/template.rb:157:in `render'
deface (1.5.0) lib/deface/action_view_extensions.rb:43:in `render'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:44:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `instrument'
actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:43:in `instrument'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:16:in `render'
actionview (5.2.3) lib/action_view/renderer/renderer.rb:44:in `render_template'
actionview (5.2.3) lib/action_view/renderer/renderer.rb:25:in `render'
actionview (5.2.3) lib/action_view/rendering.rb:103:in `_render_template'
actionpack (5.2.3) lib/action_controller/metal/streaming.rb:219:in `_render_template'
actionview (5.2.3) lib/action_view/rendering.rb:84:in `render_to_body'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (5.2.3) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
actionpack (5.2.3) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
activesupport (5.2.3) lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
C:/Ruby25-x64/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
activesupport (5.2.3) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:46:in `block in render'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (5.2.3) lib/active_record/railties/controller_runtime.rb:31:in `cleanup_view_runtime'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:45:in `render'
responders (3.0.0) lib/action_controller/responder.rb:240:in `default_render'
responders (3.0.0) lib/action_controller/responder.rb:172:in `to_html'
spree_core (3.7.3) lib/spree/responder.rb:18:in `to_html'
responders (3.0.0) lib/action_controller/responder.rb:165:in `respond'
responders (3.0.0) lib/action_controller/responder.rb:158:in `call'
responders (3.0.0) lib/action_controller/respond_with.rb:213:in `respond_with'
spree_core (3.7.3) lib/spree/core/controller_helpers/respond_with.rb:16:in `respond_with'
spree_backend (3.7.3) app/controllers/spree/admin/properties_controller.rb:5:in `index'
actionpack (5.2.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (5.2.3) lib/abstract_controller/base.rb:194:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.2.3) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (5.2.3) lib/active_support/callbacks.rb:132:in `run_callbacks'
actionpack (5.2.3) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `instrument'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
activerecord (5.2.3) lib/active_record/railties/controller_runtime.rb:24:in `process_action'
actionpack (5.2.3) lib/abstract_controller/base.rb:134:in `process'
actionview (5.2.3) lib/action_view/rendering.rb:32:in `process'
actionpack (5.2.3) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (5.2.3) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:34:in `serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:52:in `block in serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `each'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `serve'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:840:in `call'
railties (5.2.3) lib/rails/engine.rb:524:in `call'
railties (5.2.3) lib/rails/railtie.rb:190:in `public_send'
railties (5.2.3) lib/rails/railtie.rb:190:in `method_missing'
actionpack (5.2.3) lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>'
actionpack (5.2.3) lib/action_dispatch/routing/mapper.rb:48:in `serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:52:in `block in serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `each'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `serve'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:840:in `call'
versioncake (3.4.0) lib/versioncake/rack/middleware.rb:17:in `call'
warden (1.2.8) lib/warden/manager.rb:36:in `block in call'
warden (1.2.8) lib/warden/manager.rb:34:in `catch'
warden (1.2.8) lib/warden/manager.rb:34:in `call'
rack (2.0.7) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.0.7) lib/rack/etag.rb:25:in `call'
rack (2.0.7) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.7) lib/rack/head.rb:12:in `call'
actionpack (5.2.3) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.0.7) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.7) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/cookies.rb:670:in `call'
activerecord (5.2.3) lib/active_record/migration.rb:559:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.3) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.7.0) lib/web_console/middleware.rb:30:in `block in call'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.3) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.7) lib/rack/method_override.rb:22:in `call'
rack (2.0.7) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.7) lib/rack/sendfile.rb:111:in `call'
webpacker (4.0.7) lib/webpacker/dev_server_proxy.rb:29:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (5.2.3) lib/rails/engine.rb:524:in `call'
puma (3.12.1) lib/puma/configuration.rb:227:in `call'
puma (3.12.1) lib/puma/server.rb:660:in `handle_request'
puma (3.12.1) lib/puma/server.rb:474:in `process_client'
puma (3.12.1) lib/puma/server.rb:334:in `block in run'
puma (3.12.1) lib/puma/thread_pool.rb:135:in `block in spawn_thread'

Add high-level description

Hello!
I have installed this extension and now can see vendors tab in my admin panel.
Also, i can fill vendor field when creating user, but then i am stack.
It would be cool if you, guys, can provide some description how your extension works and how to use it =)

NameError (uninitialized constant SpreeMultiVendor::Spree::Preferences)

Context

In my app, calling SpreeMultiVendor::Spree::Preferences in rails c results in NameError.

So I cannot execute any rake task. 😭

# bin/rails c
Running via Spring preloader in process 276
Loading development environment (Rails 6.1.3)
[1] pry(main)> SpreeMultiVendor::Configuration
NameError: uninitialized constant SpreeMultiVendor::Spree::Preferences
from /usr/local/lib/ruby/gems/3.0.0/bundler/gems/spree_multi_vendor-bf37f0624cc1/app/models/spree_multi_vendor/configuration.rb:2:in `<module:SpreeMultiVendor>'

Expected Behavior

no errors.

Actual Behavior

NameError.(see above)

Possible Fix

  1. set config.eager_load=true and config.cache_classes = true (and stop spring)

Or

  1. Fork and patch this.
--- a/app/models/spree_multi_vendor/configuration.rb
+++ b/app/models/spree_multi_vendor/configuration.rb
@@ -1,5 +1,5 @@
 module SpreeMultiVendor
-  class Configuration < Spree::Preferences::Configuration
+  class Configuration < ::Spree::Preferences::Configuration
     DEFAULT_VENDORIZED_MODELS ||= %w[product variant stock_location shipping_method].freeze

    # Some example preferences are shown below, for more information visit:

Steps to Reproduce

For example, in spec/dummy (created by bundle exec rake test_app) in this repo.

  1. (bundle exec rake test_app)
  2. cd spec/dummy
  3. BUNDLE_GEMFILE=../../Gemfile bundle exec rails c
  4. Type SpreeMultiVendor::Spree::Preferences and hit Enter
[dummy]$ BUNDLE_GEMFILE=../../Gemfile bundle exec rails c
/Users/hoshino/go/src/github.com/route06/spree_multi_vendor/app/models/spree_multi_vendor/spree/order_decorator.rb:69: warning: already initialized constant SpreeMultiVendor::Spree::OrderDecorator::METHOD_NAMES
/Users/hoshino/go/src/github.com/route06/spree_multi_vendor/app/models/spree_multi_vendor/spree/order_decorator.rb:69: warning: previous definition of METHOD_NAMES was here
Loading development environment (Rails 6.1.3)
irb(main):001:0> SpreeMultiVendor::Configuration
Traceback (most recent call last):
        1: from (irb):1:in `<main>'
NameError (uninitialized constant SpreeMultiVendor::Spree::Preferences)

version

spree-contrib/master bf37f06

Error when trying to create a product as a vendor

Steps taken

Create a brand new spree install following the directions in the docs. Install the multi vendor extension and ran the migrations.

I log in as the vendor and attempt to create a product and I get an error Authorization Failure when I select a prototype.

Also I can't create prototypes when logged in as a vendor.

undefined method vendor_path for product

You add the add_vendor_info_to_products_show.rb override but there is no routes to vendor in config/routes.rb

May be you could add to your config/routes.rb:
Spree::Core::Engine.add_routes do
resources :vendors, only: :show
end

..and would be right adding a controller and the view for the show action.

undefined method `vendor_path'

Hi!

I just bumped into this error after having cranked up a fresh spree store locally. Possibly related to #145.

How to reproduce

  1. Set up spree store with sample data according to the getting started guide.
  2. Set up multi-vendor extension according to the installation instructions, creating a test vendor.
  3. Assigned the sample product a-line-suede-skirt to the test vendor.
  4. Clicked on the product a-line-suede-skirt in the store front.

Result

Screenshot 2020-12-02 at 08 22 57

Gemfile

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.7.2'


gem 'spree', '~> 4.1'
gem 'spree_auth_devise', '~> 4.2'
gem 'spree_gateway', '~> 3.9'

gem 'spree_i18n', github: 'spree-contrib/spree_i18n'
gem 'spree_multi_vendor', github: 'spree-contrib/spree_multi_vendor'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.4'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]


None of the advertised features accessible

Developers are wasting time using this gem, all it does is that it tags a user as a vendor, and add some view partials. The whole reason people are installing the gem is because they want a vendor dashboard where vendors upload their own products. It's advertised but not included. The documentation goes nowhere beyond the installation.

Vendor dashboard

I cannot see vendor dashboard after install this gem,

Am i missing something?

All Option Types that are the same shows up on Product Index page

If two vendors sell the same kind of product with the same option types, both have to make separate option types for the same kind of options, eg sizes, yet both option types show up on the product index page. For example, Vendor A sells red shirts and Vendor B sells blue shirts. Both carry s, m, & lg sizes, which means both have to create separate Option Types. Vendor A created his option type named Size, presentation name Size, & the sizes are sm, med, & lg. Vendor B created his option type, but can't use the name Size, so he has to use Sizes. However, the presentation name is Size & he carries the same sizes. When you look on the product index page, both option types are there, with the same name and size options. Is there a way the super admin can make the option types and all vendors have access to that, instead of them making the same kind of option types that will show up repeatedly on the product index page?
Screen Shot 2020-09-25 at 7 43 48 PM

installation error

When doing:

bundle exec rails g spree_multi_vendor:install

I got the following error:

/var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/inflector/methods.rb:284:in `const_get': uninitialized constant Spree::User (NameError)                                                                                                                                                 
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/inflector/methods.rb:284:in `block in constantize'                    
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/inflector/methods.rb:280:in `each'                                    
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/inflector/methods.rb:280:in `inject'                                  
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/inflector/methods.rb:280:in `constantize'                             
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/core_ext/string/inflections.rb:68:in `constantize'                    
        from /var/lib/gems/2.7.0/gems/spree_core-4.1.12/lib/spree/core.rb:28:in `user_class'                                                         
        from /var/lib/gems/2.7.0/gems/spree_core-4.1.12/app/models/spree/order.rb:64:in `<class:Order>'                                              
        from /var/lib/gems/2.7.0/gems/spree_core-4.1.12/app/models/spree/order.rb:7:in `<module:Spree>'                                              
        from /var/lib/gems/2.7.0/gems/spree_core-4.1.12/app/models/spree/order.rb:6:in `<main>'                                                      
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'                         
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_l$i'                                                                                                                                                   
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'                          
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'       
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'                         
        from /var/lib/gems/2.7.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'                                                                 
        from /var/lib/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
        from /var/lib/gems/2.7.0/gems/spree_gateway-3.9.2/app/models/spree/apple_pay_order_decorator.rb:20:in `<main>'
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_l$i'
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        from /var/lib/gems/2.7.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
        from /var/lib/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
        from /var/lib/gems/2.7.0/gems/spree_gateway-3.9.2/app/models/spree/apple_pay_order_decorator.rb:2:in `<module:Spree>'
        from /var/lib/gems/2.7.0/gems/spree_gateway-3.9.2/app/models/spree/apple_pay_order_decorator.rb:1:in `<main>'
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
        from /var/lib/gems/2.7.0/gems/spree_gateway-3.9.2/lib/spree_gateway/engine.rb:42:in `block in activate'
        from /var/lib/gems/2.7.0/gems/spree_gateway-3.9.2/lib/spree_gateway/engine.rb:41:in `glob'
       from /var/lib/gems/2.7.0/gems/spree_gateway-3.9.2/lib/spree_gateway/engine.rb:41:in `activate'                                  [16/13091]
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:428:in `instance_exec'
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:428:in `block in make_lambda'
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:200:in `block (2 levels) in halting'
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:605:in `block (2 levels) in default_terminator'
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:604:in `catch'
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:604:in `block in default_terminator'
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:201:in `block in halting'
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:513:in `block in invoke_before'
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:513:in `each'
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:513:in `invoke_before'
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:134:in `run_callbacks'
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/reloader.rb:88:in `prepare!'
        from /var/lib/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/application/finisher.rb:113:in `block in <module:Finisher>'
        from /var/lib/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/initializable.rb:32:in `instance_exec'
        from /var/lib/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/initializable.rb:32:in `run'
        from /var/lib/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/initializable.rb:61:in `block in run_initializers'
        from /usr/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
        from /usr/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        from /usr/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
        from /usr/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
        from /usr/lib/ruby/2.7.0/tsort.rb:347:in `each'
        from /usr/lib/ruby/2.7.0/tsort.rb:347:in `call'
        from /usr/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
        from /usr/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
        from /usr/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
        from /var/lib/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/initializable.rb:60:in `run_initializers'
        from /var/lib/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/application.rb:363:in `initialize!'
        from /root/custom_spree/config/environment.rb:5:in `<main>'
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from /var/lib/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        from /var/lib/gems/2.7.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
        from /var/lib/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `block in require'
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
        from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `require'
        from /var/lib/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:106:in `preload'
        from /var/lib/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve'
        from /var/lib/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run'
        from /var/lib/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop'
        from /var/lib/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `run'
        from /var/lib/gems/2.7.0/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'
        from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
        from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
        from -e:1:in `<main>'

Ruby and rails versions (ubuntu 20.04):

$ ruby --version
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
$ gem --version
3.1.2

Issue on Vendor Settings

Hello,
On successfull installation of gem ,
I am getting an error on page "/admin/vendor settings"
And I don't see any provision to assign products to vendor

Also can you guys please provide a detailed description of the extension

Mapping of a domain with particular vendor

I am working on a spree e-commerce application for multiple vendors and multiple stores senerio.

For that I am using this gem and able to create the different vendors also.

My query is that how to map a domain for particular vendor's store ?

undefined method `vendor' when creating a new vendor

Getting NoMethodError (undefined method vendor' for nil:NilClass): when creating a new vendor while few days back same code was working Pointing error to module SpreeMultiVendor::Spree::VariantDecorator at line 10

Could not find generator 'spree_multi_vendor:install'

Am try to run the multi_vendor extension on my localhost as per instructions on github and running into the error:

Could not find generator 'spree_multi_vendor:install'. Maybe you meant 'spree_gateway:install', 'spree:auth:install' or 'spree:install'

Am on: Rails 5.2.3 an ruby:ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]

What would be the issue?

@order.vendor_total(vendor) returns incorrect amount if some items are taxable

tl;dr - When checking out with 2 items from different vendors and 1 item is taxable, the vendor totals both include the tax for the taxable item.

I have 2 items in my cart, each one $500. The first item is in a tax_category that applies tax based on zone. The other item has no tax category assigned. I am checking out with an address that is in the zone assigned to the tax_category (state based 6%) of the first item. The Spree order total is correct as it only applies tax to the taxable item. Both items have free shipping and the order total is $1,030. So far so good.

But when calling @order.vendor_total(vendor), each vendor shows that their vendor_total is $530 for an incorrect order total of $1,060. I expect one to be $530 and the other $500.

I believe this happens because of the method definition is taking the order total (with tax) and subtracting the pre-tax totals of the other vendor's items in the cart combined with the pre-tax shipment totals of other vendor's items - a calculation which leaves the entire order tax amount to be added onto every vendor_total calculation:

def vendor_total(vendor)
  // the current approach removes all other vendor's pre-tax items/shipments
  // from the tax-included order total and returns the result - which leaves the 
  // order tax to be added to each vendor separately (problem)
  total -
  line_items.not_for_vendor(vendor).sum(:pre_tax_amount) - 
  shipments.not_for_vendor(vendor).sum(:pre_tax_amount)
end

I think we should be doing something more like this to calculate vendor_total:

def vendor_total(vendor)
  // this approach adds up the items/shipments belonging to the vendor with tax if applicable
  line_items.for_vendor(vendor).sum(:pre_tax_amount) +
  line_items.for_vendor(vendor).sum(:additional_tax_total) + 
  shipments.for_vendor(vendor).sum(:cost)
end

Has anyone else run into this issue or is there some logic behind the method definition that I am missing? Will be happy to submit a PR if someone else confirms this to be an issue.

Thanks,
JD

No Vendor info

I just installed this gem and am not seeing a link for vendors in the admin's dashboard. If I type in the link (admin/vendors), I can manually add a vendor, but I can't approve or decline them - it just sits at "pending". Can someone help me with this?

Edit to add - I'm using Spree 3.7.0 and Rails 5.2.4.4

Unable to calculate shipping rates.

When no shipment methods are assigned to vendor, any order with items from that vendor will fail in the shippment state with the error "We are unable to calculate shipping rates for the selected items".

The origin for that issue its in the package_decorator.rb when you override the shipping methods:

  def shipping_methods
    if (vendor = stock_location.vendor)
      vendor.shipping_methods.to_a
    else
      shipping_categories.map(&:shipping_methods).reduce(:&).to_a
    end
  end

May be you could replace this code to allow the "default" shippments methods for any vendor unless some specific method are assigned to it. Something like this:

  def shipping_methods
    if ( (vendor = stock_location.vendor) && vendor.shipping_methods.present? )
      vendor.shipping_methods.to_a
    else
      shipping_categories.map(&:shipping_methods).reduce(:&).to_a
    end
  end

I think this is the fast solution right now but the appropriate one would be to modify the models to assign shipping methods to vendors (and not vendors to shipping_methods)

CanCan::Error in the Product Images endpoint (APIv1)

When we try to access the product images in APIv1, for a vendor product, with a user who has a vendor associated. And also, the vendor associated is active. We got a CanCan::Error.

Expected behaviour

If the product is associated with the vendor, it should return a response as in the following documentation: https://guides.spreecommerce.org/api/product_images.html#index.

Current behaviour

A CanCan::Error is displayed, as you can see in the following image.

Screenshot_20210207_221611

Steps to Reproduce

  1. Create a new rails project: rails new spree_multivendor_rails_v6_1.

  2. Setup spree: https://guides.spreecommerce.org/developer/tutorials/existing_app_tutorial.html.

  3. Setup spree_multi_vendor: https://github.com/spree-contrib/spree_multi_vendor#installation.

    • Note: You should create sample Vendor (spree_multi_vendor step 5).
  4. Run the project: bundle exec rails s.

  5. Go to: http://localhost:3000/admin/login, and sign in with the user [email protected] and password spree123.

  6. Got to: http://localhost:3000/admin/users and click the link for the user [email protected].

  7. Click the Generate API key button. It will generate the user token to use in APIv1.

  8. Go to: http://localhost:3000/admin/vendors and click the Edit button for the vendor [email protected].

  9. Change the state to Active and click the Update button.

  10. Go to: http://localhost:3000/admin/products. Since in the step 2 some sample products were created, choose anyone and click the Edit button.

  11. Go to the vendor field and select the created vendor, usually named Test Vendor.

  12. Copy the slug of the product.

  13. Go to the product images URL (API v1).

    http://localhost:3000/api/v1/products/<slug_from_step_12>/images?token=<vendor_user_token_from_step_7>
    

Now, It should display the CanCan::Error mentioned before.

Specifications

  • Ruby (ruby-2.7.1).
  • Rails (6.1.1).
  • OS (Manjaro 20.2.1 Nibia). But also tested in CentOS and MacOS.
  • Spree (4.2.0.rc5). But also tested in Spree 4.1.13.

Possible solution

As you can see in the attached image above. It's a problem with accessible_by for a block 'can' definition. According to the cancan documentation, we must provide an SQL string representing the condition to fetch the records.

Deface Overrides missing End

After Installing I would get an error when trying to render Properties#index.

After digging into this I found the issue to be cause by the deface not including the appropriate <% end %> tags.

The change was to use surround instead of insert_after and adding <%= render_original %><% end %> to the text.

I resolved this by updating the deface overrides as described above:
Original:

Deface::Override.new(
virtual_path: 'spree/admin/properties/index',
name: 'check_first_vendor_name',
insert_before: '.row:last-of-type',
text: '<% if current_spree_user.respond_to?(:has_spree_role?) && current_spree_user.has_spree_role?(:admin) && params[:vendor_name_not_null] %>'
)

Update:

Deface::Override.new(
    virtual_path: 'spree/admin/properties/index',
    name: 'check_first_vendor_name',
    surround: '.row:last-of-type',
    text: '<% if current_spree_user.respond_to?(:has_spree_role?) && current_spree_user.has_spree_role?(:admin) && params[:vendor_name_not_null] %><%= render_original %><% end %>'
)

Original:

Deface::Override.new(
virtual_path: 'spree/admin/properties/index',
name: 'check_second_vendor_name',
insert_before: 'tr[data-hook="listing_properties_header"] th:nth-child(3)',
text: '<% if current_spree_user.respond_to?(:has_spree_role?) && current_spree_user.has_spree_role?(:admin) && params[:vendor_name_not_null] %>'
)

Update:

Deface::Override.new(
    virtual_path: 'spree/admin/properties/index',
    name: 'check_second_vendor_name',
    surround: 'tr[data-hook="listing_properties_header"] th:nth-child(3)',
    text: '<% if current_spree_user.respond_to?(:has_spree_role?) && current_spree_user.has_spree_role?(:admin) && params[:vendor_name_not_null] %><%= render_original %><% end %>'
)

Original:

Deface::Override.new(
virtual_path: 'spree/admin/properties/index',
name: 'check_third_vendor_name',
insert_before: 'tr[data-hook="listing_properties_row"] td:nth-child(3)',
text: '<% if current_spree_user.respond_to?(:has_spree_role?) && current_spree_user.has_spree_role?(:admin) && property.respond_to?(:vendor) %>'
)

Update:

Deface::Override.new(
    virtual_path: 'spree/admin/properties/index',
    name: 'check_third_vendor_name',
    surround: 'tr[data-hook="listing_properties_row"] td:nth-child(3)',
    text: '<% if current_spree_user.respond_to?(:has_spree_role?) && current_spree_user.has_spree_role?(:admin) && property.respond_to?(:vendor) %><%= render_original %><% end %>'
)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.