Sha256: b3186912d03f7f3618085939d42f71ec3513c4cc35c7c44e57308fc0b7639b3f

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

module Plugins::Ecommerce::EcommerceEmailHelper
  include CamaleonCms::EmailHelper

  def send_order_received_email(order)
    extra_data = {
      :fullname => order.customer.fullname,
      :order_slug => order.slug,
      :order_url => plugins_ecommerce_order_show_url(order: order.slug),
      :billing_information => order.get_meta('billing_address'),
      :shipping_address => order.get_meta('shipping_address'),
      :subtotal => order.get_meta("payment")[:total],
      :total_cost => order.get_meta("payment")[:amount],
      :order => order
    }
    send_email(order.customer.email, t('plugin.ecommerce.email.order_received.subject'), '', nil, [], 'order_received', 'plugins/ecommerce/mailer', extra_data)
  end

  def send_order_received_admin_notice(order)
    extra_data = {
      :fullname => order.customer.fullname,
      :order_slug => order.slug,
      :order_url => plugins_ecommerce_order_show_url(order: order.slug),
      :billing_information => order.get_meta('billing_address'),
      :shipping_address => order.get_meta('shipping_address'),
      :subtotal => order.get_meta("payment")[:total],
      :total_cost => order.get_meta("payment")[:amount],
      :order => order
    }

    users = current_site.users.where(:role => :admin)
    users.each do |user|
      extra_data[:admin] = user
      send_email(user.email, t('plugin.ecommerce.email.order_received_admin.subject'), '', nil, [], 'order_received_admin', 'plugins/ecommerce/mailer', extra_data)
    end
  end

  def send_recovery_cart_email(order)
    extra_data = {
      :fullname => order.customer.fullname,
      :order => order
    }
    send_email(order.customer.email, t('plugin.ecommerce.email.recovery_cart.subject'), '', nil, [], 'recovery_cart', 'plugins/ecommerce/mailer', extra_data)
    Rails.logger.info "Send recovery to #{order.customer.email} with order #{order.slug}"
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
camaleon_ecommerce-0.0.4 app/helpers/plugins/ecommerce/ecommerce_email_helper.rb