Class: Workarea::MailChimp::Cart
- Inherits:
-
Object
- Object
- Workarea::MailChimp::Cart
- Includes:
- I18n::DefaultUrlOptions
- Defined in:
- app/services/workarea/mail_chimp/cart.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
Instance Method Summary collapse
-
#initialize(order, options = {}) ⇒ Cart
constructor
A new instance of Cart.
-
#to_h ⇒ Object
Hash.
Constructor Details
#initialize(order, options = {}) ⇒ Cart
Returns a new instance of Cart.
9 10 11 12 |
# File 'app/services/workarea/mail_chimp/cart.rb', line 9 def initialize(order, = {}) @order = order @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'app/services/workarea/mail_chimp/cart.rb', line 7 def @options end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
7 8 9 |
# File 'app/services/workarea/mail_chimp/cart.rb', line 7 def order @order end |
Instance Method Details
#to_h ⇒ Object
Returns Hash.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/services/workarea/mail_chimp/cart.rb', line 15 def to_h cart_hsh = { id: order.id.to_s, currency_code: order.total_price.currency.iso_code, order_total: order.total_price.to_s, tax_total: order.tax_total.to_s, shipping_total: order.shipping_total.to_s, lines: lines, customer: customer, checkout_url: Storefront::Engine.routes.url_helpers.resume_cart_url(token: order.token, host: Workarea.config.host), } # Mailchimp api does not accept empty values for campaign ID # only merge in if the campaign ID is present cart_hsh.merge!(campaign_id: order.mail_chimp_campaign_id) if order.mail_chimp_campaign_id.present? cart_hsh end |