VietTH: Feature stock management
{{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
-
Status changed to merged
Toggle commit list
| 1 | 1 | class OrderService < BaseService |
| 2 | 2 | |
| 3 | def create(order_params) | |
| 4 | order = current_user.orders.build(order_params) | |
| 5 | ||
| 6 | product_ids = [] | |
| 7 | quantites = {} | |
| 8 | order_params['order_items_attributes'].each do |item| | |
| 9 | id = item.last['product_id'] | |
| 10 | product_ids << id | |
| 11 | quantites[id] = item.last['quantity'] | |
| 12 | end | |
| 3 | def add_to_cart product | |
Please
register
or
sign in
to reply
|
||
| 26 | 24 | end |
| 27 | 25 | |
| 28 | 26 | def add_cart |
| 29 | add_to_cart(@product) | |
| 30 | redirect_to(@product, notice: 'Product is added to cart.') | |
| 27 | result = order_service.add_to_cart(@product) | |
|
||
| 1 | 1 | class OrderItem < ActiveRecord::Base |
| 2 | 2 | belongs_to :order |
| 3 | 3 | belongs_to :product |
| 4 | ||
| 5 | before_save :update_product_quantity | |
|
||
| 1 | 1 | class OrderService < BaseService |
| 2 | 2 | |
| 3 | def create(order_params) | |
| 4 | order = current_user.orders.build(order_params) | |
| 5 | ||
| 6 | product_ids = [] | |
| 7 | quantites = {} | |
| 8 | order_params['order_items_attributes'].each do |item| | |
| 9 | id = item.last['product_id'] | |
| 10 | product_ids << id | |
| 11 | quantites[id] = item.last['quantity'] | |
| 12 | end | |
| 3 | def add_to_cart product | |
|
||
| 1 | 1 | class OrderItem < ActiveRecord::Base |
| 2 | 2 | belongs_to :order |
| 3 | 3 | belongs_to :product |
| 4 | ||
| 5 | before_save :update_product_quantity | |
|
||
| 26 | 24 | end |
| 27 | 25 | |
| 28 | 26 | def add_cart |
| 29 | add_to_cart(@product) | |
| 30 | redirect_to(@product, notice: 'Product is added to cart.') | |
| 27 | result = order_service.add_to_cart(@product) | |
|
||
| 1 | 1 | class OrderItem < ActiveRecord::Base |
| 2 | 2 | belongs_to :order |
| 3 | 3 | belongs_to :product |
| 4 | ||
| 5 | before_save :update_product_quantity | |
|
||
| 1 | 1 | class OrderService < BaseService |
| 2 | 2 | |
| 3 | def create(order_params) | |
| 4 | order = current_user.orders.build(order_params) | |
| 5 | ||
| 6 | product_ids = [] | |
| 7 | quantites = {} | |
| 8 | order_params['order_items_attributes'].each do |item| | |
| 9 | id = item.last['product_id'] | |
| 10 | product_ids << id | |
| 11 | quantites[id] = item.last['quantity'] | |
| 12 | end | |
| 3 | def add_to_cart product | |
|
||
| 26 | 24 | end |
| 27 | 25 | |
| 28 | 26 | def add_cart |
| 29 | add_to_cart(@product) | |
| 30 | redirect_to(@product, notice: 'Product is added to cart.') | |
| 27 | result = order_service.add_to_cart(@product) | |
|
||
Added 1 commit:
Added 1 commit:
Added 1 commit:
Added 1 commit:
Added 1 commit:
Added 1 commit:
Status changed to merged
Status changed to merged
mentioned in commit f04cca90
mentioned in commit f04cca90