New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OrderPopulator is deprecated. 404 when trying to add items to cart (Spree - 2.4.5) #6195
Comments
I'm pretty sure this is a duplicate of #2210 not sure if you're trying to use a respond_override though. If not I believe you're customizing something that causes a ActiveRecord find that fails to find a record causing the 404 error. |
Actually just noticed you're not submitting a variant_id parameter. So you're probably hitting 404 trying to look up the variant to add: https://github.com/spree/spree/blob/2-4-stable/core/app/models/spree/order_populator.rb#L35 |
Thank you for your reply. I noticed it with the missing variant id but not sure how to add one in because my populate method and add to cart are all standard spree ones. I haven't played around with the methods. My order_populator is unedited too (exactly the same as the one you linked). I am not using a respond_override either. What do you recommend I should do? I could always pass in the variant_id through a hidden field as a quick fix? |
Yea your cart form should include the variant id so if your customizing it you need to make sure to pass the variant id. By default if there are variants we render radio tags, and if there are no variants we just put the master id in a hidden field: |
Fantastic! Thank you for your help. My _cart_form partial was missing the part you linked. All working now. Cheers. |
I am getting a 404 error when trying to add items to the cart.
Started POST "/orders/populate" for 127.0.0.1 at 2015-03-18 12:19:41 +1300
Processing by Spree::OrdersController#populate as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"X7X/Y/2QtRSflHG3PWSU+tXU9nEoP7posRsQYkXltHQ=", "quantity"=>"1", "button"=>""}
Spree::Preference Load (1.0ms) SELECT
spree_preferences
.* FROMspree_preferences
WHEREspree_preferences
.key
= 'spree/frontend_configuration/locale' LIMIT 1Spree::User Load (1.0ms) SELECT
spree_users
.* FROMspree_users
WHEREspree_users
.deleted_at
IS NULL ANDspree_users
.id
= 1 ORDER BYspree_users
.id
ASC LIMIT 1Spree::Store Load (0.0ms) SELECT
spree_stores
.* FROMspree_stores
WHERE (url like '%localhost%') ORDER BYspree_stores
.id
ASC LIMIT 1Spree::Store Load (0.0ms) SELECT
spree_stores
.* FROMspree_stores
WHEREspree_stores
.default
= 1 ORDER BYspree_stores
.id
ASC LIMIT 1Spree::Order Load (0.0ms) SELECT
spree_orders
.* FROMspree_orders
WHEREspree_orders
.completed_at
IS NULL ANDspree_orders
.currency
= 'NZD' ANDspree_orders
.guest_token
= 'TNsLJs_p59-PuKjawl31Yg' ANDspree_orders
.store_id
= 1 ANDspree_orders
.user_id
= 1 LIMIT 1Spree::Order Load (1.0ms) SELECT
spree_orders
.* FROMspree_orders
WHEREspree_orders
.user_id
= 1 ANDspree_orders
.completed_at
IS NULL ORDER BY created_at DESC LIMIT 1Spree::Order Load (1.0ms) SELECT
spree_orders
.* FROMspree_orders
WHEREspree_orders
.user_id
= 1 ANDspree_orders
.completed_at
IS NULL AND (id != 2)Spree::Product Load (1.0ms) SELECT
spree_products
.* FROMspree_products
WHEREspree_products
.deleted_at
IS NULL AND (deleted_at is NULL) ORDER BYspree_products
.id
DESC LIMIT 3CACHE (0.0ms) SELECT
spree_products
.* FROMspree_products
WHEREspree_products
.deleted_at
IS NULL AND (deleted_at is NULL) ORDER BYspree_products
.id
DESC LIMIT 3Spree::Order Load (0.0ms) SELECT
spree_orders
.* FROMspree_orders
WHEREspree_orders
.number
IS NULL LIMIT 1(1.0ms) SELECT COUNT(*) FROM
spree_roles
INNER JOINspree_roles_users
ONspree_roles
.id
=spree_roles_users
.role_id
WHEREspree_roles_users
.user_id
= 1 ANDspree_roles
.name
= 'admin'DEPRECATION WARNING: OrderPopulator is deprecated and will be removed from Spree 3, use OrderContents with order.contents.add instead. (called from populate at C:/ruby/hitechplastics/app/controllers/spree/orders_controller.rb:45)
Rendered public/404.html (0.0ms)
Completed 404 Not Found in 454ms (Views: 405.0ms | ActiveRecord: 6.0ms)
Here is my populate method from orders_controller (standard from spree 2.4.5)
And my gemfile
source 'https://rubygems.org'
gem 'rails', '4.1.8'
gem 'mysql2'
gem 'sass-rails', '
> 4.0.3'> 4.0.0'gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '
> 2.0'> 0.4.0', group: :docgem 'sdoc', '
gem 'tzinfo-data', platforms: [:mingw, :mswin]
gem 'spree', '2.4.5'
gem 'spree_gateway', git: 'https://github.com/spree/spree_gateway', branch: '2-4-stable'
gem 'spree_auth_devise', git: 'https://github.com/spree/spree_auth_devise', branch: '2-4-stable'
gem 'spree_bootstrap_frontend', git: 'https://github.com/200Creative/spree_bootstrap_frontend', branch: '2-4-stable'
gem 'spree_static_content', git: 'https://github.com/spree/spree_static_content', branch: '2-4-stable'
gem 'spree_editor', git: 'https://github.com/spree-contrib/spree_editor', branch: '2-4-stable'
gem 'spree_mail_settings', git: 'https://github.com/spree-contrib/spree_mail_settings', branch: '2-4-stable'
gem 'coffee-script-source', '1.8.0'
gem 'therubyracer', :platforms => :ruby
gem 'multi_json', '~> 1.10.1'
Please let me know if there is anything else you need to help me with this issue.
Thanks in advance.
The text was updated successfully, but these errors were encountered: