如何将添加到购物车按钮添加到目录中的每个产品?我创建了链接
<%= link_to fast_cart_path do %>
Add To Cart
<% end %>
以及操作,OrdersController#update 的副本
def fast_cart
populator = Spree::OrderPopulator.new(current_order(true), current_currency)
if populator.populate(params.slice(:products, :variants, :quantity))
current_order.create_proposed_shipments if current_order.shipments.any?
fire_event('spree.cart.add')
fire_event('spree.order.contents_changed')
respond_with(@order) do |format|
format.html { redirect_to cart_path }
end
else
flash[:error] = populator.errors.full_messages.join(" ")
redirect_to :back
end
end
我没有任何错误,但由于某种原因产品未添加到购物车。