14 lines
360 B
Ruby
14 lines
360 B
Ruby
# module to copy one object into other
|
|
module CheckoutHelper
|
|
def copy_cart_prod_to_order(cart, order)
|
|
return unless order.order_products.blank?
|
|
cart.cart_products.each do |cp|
|
|
op = OrderProduct.new(order_id: order.id)
|
|
op.product_id = cp.product_id
|
|
op.quantity = cp.quantity
|
|
op.price = cp.price
|
|
op.save
|
|
end
|
|
end
|
|
end
|