Class: Dropwallet::Core::Cart
- Defined in:
- lib/dropwallet/core/cart.rb
Instance Method Summary collapse
-
#addItem(item) ⇒ Object
Adds an item to the current cart.
-
#merge(userId) ⇒ Object
Merges a cookie cart with a user cart, returns the ID of the newly merged user cart.
-
#paymentMethodId ⇒ Object
Override the default behavior for Payment Method ID.
-
#shippingAddressId ⇒ Object
Override the default behavior for Shipping Address ID.
Methods inherited from Model
all, baseServiceUrl, count, create, debug?, delete, #delete, field, find, #initialize, #isNew?, pages, #read_attribute, #read_attribute_for_validation, #save, serviceUrl, #to_json, #to_s, #update, #write_attribute
Constructor Details
This class inherits a constructor from Dropwallet::Core::Model
Instance Method Details
#addItem(item) ⇒ Object
Adds an item to the current cart.
13 14 15 16 17 |
# File 'lib/dropwallet/core/cart.rb', line 13 def addItem(item) = {:path => "#{Dropwallet::Core::Model.baseServiceUrl}/carts/#{cartId}/items"} doc = JSON.parse(RestClient.post([:path], item, {:accept => :json })) return doc end |
#merge(userId) ⇒ Object
Merges a cookie cart with a user cart, returns the ID of the newly merged user cart.
20 21 22 23 24 |
# File 'lib/dropwallet/core/cart.rb', line 20 def merge(userId) = {:path => "#{Dropwallet::Core::Model.baseServiceUrl}/carts/#{cartId}/mergecart/#{userId}"} doc = JSON.parse(RestClient.post([:path], item, {:accept => :json })) return doc['cartId'] end |
#paymentMethodId ⇒ Object
Override the default behavior for Payment Method ID
35 36 37 38 39 40 41 |
# File 'lib/dropwallet/core/cart.rb', line 35 def paymentMethodId if self.attributes.include? 'paymentMethodId' return self.attributes['paymentMethodId'] else return 0 end end |
#shippingAddressId ⇒ Object
Override the default behavior for Shipping Address ID
27 28 29 30 31 32 33 |
# File 'lib/dropwallet/core/cart.rb', line 27 def shippingAddressId if self.attributes.include? 'shippingAddressId' return self.attributes['shippingAddressId'] else return 0 end end |