Class: ShopifyDashboardPlus::DiscountReport
- Defined in:
- lib/shopify_dashboard_plus/report.rb
Constant Summary
Constants included from ApplicationHelpers
ApplicationHelpers::DESIRED_FIELDS
Instance Method Summary collapse
Methods inherited from Report
Methods included from ApplicationHelpers
#close_connection, #connected?, #date_range_valid?, #date_today, #days, #display_as_currency, #get_average_revenue, #get_daily_revenues, #get_date_range, #get_detailed_revenue_metrics, #get_host, #get_list_of_orders, #get_total_revenue, #hash_to_graph_format, #open_connection, #order_parameters_paginate, #set_connection, #shop_name, #strip_protocol
Constructor Details
This class inherits a constructor from ShopifyDashboardPlus::Report
Instance Method Details
#discount_usage ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/shopify_dashboard_plus/report.rb', line 122 def discount_usage discount_value, discount_used = Hash.new(0.0), Hash.new(0) @orders.each do |order| if order.attributes['discount_codes'] order.discount_codes.each do |discount_code| discount_value[discount_code.code] = discount_value[discount_code.code].plus(discount_code.amount) discount_used[discount_code.code] += 1 end end end { :discount_savings => discount_value, :discount_quantity => discount_used } end |
#to_h ⇒ Object
139 140 141 |
# File 'lib/shopify_dashboard_plus/report.rb', line 139 def to_h discount_usage end |