Sha256: 4710834c727e4fa157d24a13161c1259d8f1b93da985ae4b25c80a65d2bb1daf

Contents?: true

Size: 907 Bytes

Versions: 1

Compression:

Stored size: 907 Bytes

Contents

module Bodega
  module CartHelper
    protected
    def current_order
      @current_order ||= Bodega::Order.new.tap do |order|
        #begin
          if Bodega.config.customer_method
            order.customer = send(Bodega.config.customer_method)
          end
        #rescue NoMethodError
          raise "Please configure Bodega.config.customer_method to point to a valid method for accessing a customer record (default: current_user)"
        #end
        order.order_products = current_products.map do |type, product|
          product = product.symbolize_keys
          OrderProduct.new do |order_product|
            order_product.product_type = product[:type]
            order_product.product_id = product[:id]
            order_product.quantity = product[:quantity]
          end
        end
      end
    end

    def current_products
      session[:bodega_products] ||= {}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bodega-0.2.0 app/helpers/bodega/cart_helper.rb