spree_bronto 3.pre.0.pre.stable
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +1 -0
- data/Gemfile +8 -0
- data/LICENSE +26 -0
- data/README.md +73 -0
- data/Rakefile +21 -0
- data/app/assets/javascripts/spree/backend/spree_bronto.js +4 -0
- data/app/assets/javascripts/spree/frontend/bronto_list.js.coffee +8 -0
- data/app/assets/javascripts/spree/frontend/spree_bronto.js +2 -0
- data/app/assets/stylesheets/spree/backend/spree_bronto.css +4 -0
- data/app/assets/stylesheets/spree/frontend/spree_bronto.css +4 -0
- data/app/controllers/spree/admin/bronto_lists_controller.rb +24 -0
- data/app/controllers/spree/checkout_controller_decorator.rb +23 -0
- data/app/controllers/spree/home_controller_decorator.rb +120 -0
- data/app/controllers/spree/lists.rb +152 -0
- data/app/controllers/spree/orders_controller_decorator.rb +56 -0
- data/app/controllers/spree/users_controller_decorator.rb +27 -0
- data/app/mailers/spree/order_mailer/_order_cancel_html.html.erb +4 -0
- data/app/mailers/spree/order_mailer/_order_cancel_plain.erb +7 -0
- data/app/mailers/spree/order_mailer/_order_confirm_html.html.erb +5 -0
- data/app/mailers/spree/order_mailer/_order_confirm_plain.erb +7 -0
- data/app/mailers/spree/order_mailer/_order_details_html.html.erb +52 -0
- data/app/mailers/spree/order_mailer/_order_details_plain.erb +22 -0
- data/app/mailers/spree/order_mailer/_order_shipped_html.html.erb +20 -0
- data/app/mailers/spree/order_mailer/_order_shipped_plain.erb +21 -0
- data/app/mailers/spree/user_mailer/_password_reset_instructions.html.erb +9 -0
- data/app/mailers/spree/user_mailer_decorator.rb +13 -0
- data/app/models/spree/bronto_configuration.rb +12 -0
- data/app/models/spree/bronto_list.rb +20 -0
- data/app/models/spree/order_decorator.rb +30 -0
- data/app/models/spree/shipment_decorator.rb +18 -0
- data/app/models/spree/shipment_handler_decorator.rb +17 -0
- data/app/models/spree/store_decorator.rb +7 -0
- data/app/models/spree/user_decorator.rb +51 -0
- data/app/overrides/decorate_account_my_orders.rb +6 -0
- data/app/overrides/decorate_admin_configurations_index.rb +5 -0
- data/app/overrides/decorate_bronto_cart_recorvery.rb +6 -0
- data/app/overrides/decorate_bronto_list_subscribe.rb +6 -0
- data/app/views/spree/admin/bronto_lists/_autocomplete_form.js.erb +23 -0
- data/app/views/spree/admin/bronto_lists/_form.html.erb +49 -0
- data/app/views/spree/admin/bronto_lists/_get_lists.html.erb +1 -0
- data/app/views/spree/admin/bronto_lists/_get_lists.js.erb +1 -0
- data/app/views/spree/admin/bronto_lists/_retrieve_lists.js.erb +13 -0
- data/app/views/spree/admin/bronto_lists/edit.html.erb +11 -0
- data/app/views/spree/admin/bronto_lists/index.html.erb +38 -0
- data/app/views/spree/admin/bronto_lists/new.html.erb +11 -0
- data/app/views/spree/bronto_lists/_edit.html.erb +21 -0
- data/app/views/spree/bronto_lists/_form.html.erb +17 -0
- data/app/views/spree/bronto_lists/_signup.html.erb +13 -0
- data/app/views/spree/shared/_bronto_tags.html.erb +69 -0
- data/bin/rails +7 -0
- data/config/bronto.yml +39 -0
- data/config/locales/en.yml +27 -0
- data/config/routes.rb +19 -0
- data/db/migrate/20150427135748_spree_bronto_lists_users.rb +12 -0
- data/db/migrate/20150427135923_create_spree_bronto_lists.rb +16 -0
- data/lib/bronto_integration/bronto.rb +255 -0
- data/lib/bronto_integration/bronto_integration/communication.rb +83 -0
- data/lib/bronto_integration/bronto_integration/contact.rb +53 -0
- data/lib/bronto_integration/bronto_integration/order.rb +44 -0
- data/lib/bronto_integration/bronto_integration.rb +6 -0
- data/lib/delayed_send.rb +40 -0
- data/lib/delayed_simple_send.rb +17 -0
- data/lib/delayed_subscriber_add.rb +38 -0
- data/lib/delayed_subscriber_delete.rb +35 -0
- data/lib/delayed_subscriber_update.rb +38 -0
- data/lib/delayed_trigger.rb +17 -0
- data/lib/generators/spree_bronto/install/install_generator.rb +31 -0
- data/lib/spree_bronto/engine.rb +30 -0
- data/lib/spree_bronto/factories.rb +6 -0
- data/lib/spree_bronto.rb +2 -0
- data/spec/spec_helper.rb +87 -0
- data/spree_bronto.gemspec +32 -0
- metadata +258 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
<div align="center">
|
2
|
+
<table border="0" cellspacing="1" cellpadding="5" class="products" width="500">
|
3
|
+
<tr>
|
4
|
+
<td valign="top" align="center"><strong>QTY</strong></td>
|
5
|
+
<td valign="top"><strong>Name</strong></td>
|
6
|
+
<td valign="top" align="center"><strong>SKU</strong></td>
|
7
|
+
<td valign="top" align="center"><strong>Each</strong></td>
|
8
|
+
<td valign="top" align="center"><strong>Total</strong></td>
|
9
|
+
</tr>
|
10
|
+
<% order.line_items.each do |item| %>
|
11
|
+
<tr>
|
12
|
+
<td valign="middle" align="center" bgcolor="#ebf3f8"><%= item.quantity %></td>
|
13
|
+
<td valign="middle" align="left" bgcolor="#ebf3f8"><%= Rack::Utils.escape_html(item.variant.product.name.gsub!(/[^0-9A-Za-z]/, ' ')) %></td>
|
14
|
+
<td valign="middle" align="center" bgcolor="#ebf3f8"><%= item.variant.sku %></td>
|
15
|
+
<td valign="middle" align="center" bgcolor="#ebf3f8"><%= number_to_currency item.price %></td>
|
16
|
+
<td valign="middle" align="right" bgcolor="#ebf3f8"><%= number_to_currency(item.price * item.quantity) %></td>
|
17
|
+
</tr>
|
18
|
+
<% end %>
|
19
|
+
<tr>
|
20
|
+
<td valign="top" align="left" colspan="2" rowspan="6" class="bigger">
|
21
|
+
<br />
|
22
|
+
<p><strong>These items will be shipped to:</strong><br />
|
23
|
+
<% address=!order.ship_address ? order.bill_address : order.ship_address %>
|
24
|
+
<%= address.firstname %> <%= address.lastname %><br />
|
25
|
+
<%= address.address1 %><br />
|
26
|
+
<% unless address.address2.blank? %>
|
27
|
+
<%= address.address2 %><br />
|
28
|
+
<% end %>
|
29
|
+
<%= address.city %>
|
30
|
+
<% if address.state_id.blank? %>
|
31
|
+
<br /><%= address.state_name %><br />
|
32
|
+
<% else %>
|
33
|
+
<%= address.state.abbr %><br />
|
34
|
+
<% end %>
|
35
|
+
<%= address.country.name %> <%= address.zipcode %>
|
36
|
+
</p>
|
37
|
+
</td>
|
38
|
+
<td valign="middle" align="right" colspan="2">Sub Total</td>
|
39
|
+
<td valign="middle" align="right"><%= number_to_currency order.item_total %></td>
|
40
|
+
</tr>
|
41
|
+
<% order.adjustments.each do |adjustment| %>
|
42
|
+
<tr>
|
43
|
+
<td valign="middle" align="right" colspan="2"><%= adjustment.description %></td>
|
44
|
+
<td valign="middle" align="right"><%= number_to_currency adjustment.amount %></td>
|
45
|
+
</tr>
|
46
|
+
<% end %>
|
47
|
+
<tr>
|
48
|
+
<td valign="middle" align="right" colspan="2"><strong>Total (USD)</strong></td>
|
49
|
+
<td valign="middle" align="right"><strong><%= number_to_currency order.total %></strong></td>
|
50
|
+
</tr>
|
51
|
+
</table>
|
52
|
+
</div>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Item(s):
|
2
|
+
<% order.line_items.each_with_index do |item, i| %>
|
3
|
+
<%= "#{i}. #{item.variant.product.name.gsub!(/[^0-9A-Za-z]/, ' ')} - SKU: #{item.variant.sku} - #{item.quantity} @ #{number_to_currency item.price} ea." %>
|
4
|
+
<% end %>
|
5
|
+
|
6
|
+
Items Subtotal: <%= number_to_currency order.item_total %>
|
7
|
+
<% order.adjustments.each do |adjustment| %>
|
8
|
+
<%= adjustment.description %>: <%= number_to_currency adjustment.amount %>
|
9
|
+
<% end %>
|
10
|
+
======================
|
11
|
+
|
12
|
+
TOTAL: <%= number_to_currency order.total %>
|
13
|
+
|
14
|
+
These items will be shipped to:
|
15
|
+
<% address=!order.ship_address ? order.bill_address : order.ship_address %>
|
16
|
+
<%= address.firstname %> <%= address.lastname %>
|
17
|
+
|
18
|
+
<%= address.address1 %> <%= address.address2 unless address.address2.blank?%>
|
19
|
+
|
20
|
+
<%= address.city %> <%= address.state_id.blank? ? address.state_name : address.state.abbr%>
|
21
|
+
|
22
|
+
<%= address.country.name %> <%= address.zipcode %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<p>This email is to inform you that your order has been shipped on <%= Time.now.strftime("%B %d %Y at %I:%M %p") %>.</p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<strong>Your tracking details:</strong><br />
|
5
|
+
Package ID: <%= order.shipments.first.number %><br />
|
6
|
+
Sent date: <%= order.shipments.first.updated_at.strftime("%B %d %Y at %I:%M %p") %><br />
|
7
|
+
Shipped via: <%= order.shipments.first.shipping_method.name %><br /><br />
|
8
|
+
<%unless order.shipments.first.shipping_method.blank? || order.shipments.first.tracking.blank? %>
|
9
|
+
<%= order.shipments.first.shipping_method.name%> Tracking Number: <%= order.shipments.first.tracking %><br />
|
10
|
+
To track your package, go to:<br />
|
11
|
+
<a href="<%= order.shipments.first.shipping_method_trackurl+order.shipments.first.tracking %>"><%=order.shipments.first.shipping_method.name %> Tracking</a>
|
12
|
+
<% end %>
|
13
|
+
</p>
|
14
|
+
|
15
|
+
<p>
|
16
|
+
Here are the details of the order we received on <%= order.completed_at.strftime("%B %d %Y at %I:%M %p") %>.
|
17
|
+
</p>
|
18
|
+
<p>Your order number is <strong class="pink"><%= order.number %></strong> Please keep it for reference if you speak to a customer service representative.</p>
|
19
|
+
<p>Your <%= order.store.name %> order includes the following item(s):</p>
|
20
|
+
<%= render "order_mailer/order_details_html", :order => order %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
This email is to inform you that your order has been shipped on <%= Time.now.strftime("%B %d %Y at %I:%M %p") %>.
|
2
|
+
|
3
|
+
Your tracking details:
|
4
|
+
Package ID: <%= order.shipments.first.number %>
|
5
|
+
Sent date: <%= order.shipments.first.updated_at.strftime("%B %d %Y at %I:%M %p") %>
|
6
|
+
Shipped via: <%= order.shipments.first.shipping_method.name %>
|
7
|
+
|
8
|
+
<%unless order.shipments.first.shipping_method.blank? || order.shipments.first.tracking.blank? %>
|
9
|
+
<%= order.shipments.first.shipping_method.name%> Tracking Number: <%= order.shipments.first.tracking %>
|
10
|
+
|
11
|
+
To track your package, go to:
|
12
|
+
<%= order.shipments.first.shipping_method.trackurl+order.shipments.first.tracking%>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
Here are the details of the order we received on <%= order.completed_at.strftime("%B %d %Y at %I:%M %p") %>.
|
16
|
+
|
17
|
+
Your order number is <%= order.number %> Please keep it for reference if you speak to a customer service representative.
|
18
|
+
|
19
|
+
Your <%= order.store.name %> order includes the following item(s):
|
20
|
+
|
21
|
+
<%= render "order_mailer/order_details_plain", :order => order %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%
|
2
|
+
Rails.logger.error( "#{"\n" * 40}#{"@" * 80}" )
|
3
|
+
Rails.logger.error( @key )
|
4
|
+
Rails.logger.error( "#{"@" * 80}#{"\n" * 40}" )
|
5
|
+
user_order=@user.orders.select{|o| o.state!='in_progress'}.last
|
6
|
+
-%>
|
7
|
+
external_key: <%= Spree::BrontoConfiguration.account[current_store.code]['ET_password_reset']%>
|
8
|
+
firstname: <%= user_order.ship_address.firstname unless !user_order %>
|
9
|
+
SENDTIME__CONTENT1: <%= @user.perishable_token %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Spree::UserMailer.class_eval do
|
2
|
+
def reset_password_instructions(user, token, *args)
|
3
|
+
# we do not user this any more
|
4
|
+
end
|
5
|
+
|
6
|
+
|
7
|
+
def confirmation_instructions(user, token, opts={})
|
8
|
+
@confirmation_url = spree.spree_user_confirmation_url(:confirmation_token => token, :host => Spree::Store.current.url)
|
9
|
+
|
10
|
+
mail to: user.email, from: from_address, subject: Spree::Store.current.name + ' ' + I18n.t(:subject, :scope => [:devise, :mailer, :confirmation_instructions])
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Spree
|
2
|
+
class BrontoConfiguration
|
3
|
+
|
4
|
+
def self.account
|
5
|
+
bronto_yml=File.join(Rails.root,'config/bronto.yml')
|
6
|
+
if File.exist? bronto_yml
|
7
|
+
bronto_yml=File.join(Rails.root,'config/bronto.yml')
|
8
|
+
YAML.load(File.read(bronto_yml))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Spree
|
2
|
+
class BrontoList < ActiveRecord::Base
|
3
|
+
has_and_belongs_to_many :users, class_name: "Spree::User", join_table: :spree_bronto_lists_users
|
4
|
+
belongs_to :store, class_name: "Spree::Store"
|
5
|
+
validates_presence_of :title
|
6
|
+
validates_uniqueness_of :list_id, :message => I18n.t("bronto.validate_unique")
|
7
|
+
#validates_numericality_of :list_id
|
8
|
+
|
9
|
+
scope :by_store, lambda { |store| joins(:stores).where("spree_bronto_lists.store_id = ?", store) }
|
10
|
+
|
11
|
+
def validate
|
12
|
+
if self.new_record?
|
13
|
+
errors.add_to_base I18n.translate("bronto.only_list_can_subscribe_all") if self.subscribe_all_new_users && BrontoList.exists?(["subscribe_all_new_users = ?" , true])
|
14
|
+
else
|
15
|
+
errors.add_to_base I18n.translate("bronto.only_list_can_subscribe_all") if self.subscribe_all_new_users && BrontoList.exists?(["subscribe_all_new_users = ? AND id <> ?" , true, self.id])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Spree::Order.class_eval do
|
2
|
+
|
3
|
+
def deliver_order_confirmation_email
|
4
|
+
#OrderMailer.confirm_email(id).deliver_later # we replace OrderMailer with DelayedSend
|
5
|
+
|
6
|
+
external_key = Spree::BrontoConfiguration.account[store.code]["order_received"]
|
7
|
+
DelayedSend.new( store.code,
|
8
|
+
email,
|
9
|
+
external_key,
|
10
|
+
id.to_s,
|
11
|
+
"order_mailer/order_confirm_plain",
|
12
|
+
"order_mailer/order_confirm_html").perform
|
13
|
+
|
14
|
+
update_column(:confirmation_delivered, true)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def send_cancel_email
|
19
|
+
#OrderMailer.cancel_email(id).deliver_later
|
20
|
+
|
21
|
+
external_key = Spree::BrontoConfiguration.account[store.code]['order_canceled']
|
22
|
+
DelayedSend.new( store.code,
|
23
|
+
email,
|
24
|
+
external_key,
|
25
|
+
id.to_s,
|
26
|
+
"order_mailer/order_cancel_plain",
|
27
|
+
"order_mailer/order_cancel_html").perform
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Spree
|
2
|
+
Shipment.class_eval do
|
3
|
+
|
4
|
+
private
|
5
|
+
def send_shipped_email
|
6
|
+
#ShipmentMailer.shipped_email(id).deliver_later
|
7
|
+
|
8
|
+
external_key = Spree::BrontoConfiguration.account[order.store.code]["order_shipped"]
|
9
|
+
|
10
|
+
DelayedSend.new( order.store.code,
|
11
|
+
order.email,
|
12
|
+
external_key,
|
13
|
+
order.id.to_s,
|
14
|
+
"order_mailer/order_shipped_plain",
|
15
|
+
"order_mailer/order_shipped_html").perform
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Spree::ShipmentHandler.class_eval do
|
2
|
+
|
3
|
+
private
|
4
|
+
def send_shipped_email
|
5
|
+
#ShipmentMailer.shipped_email(id).deliver_later
|
6
|
+
order=@shipment.order
|
7
|
+
external_key = Spree::BrontoConfiguration.account[order.store.code]["order_shipped"]
|
8
|
+
|
9
|
+
DelayedSend.new( order.store.code,
|
10
|
+
order.email,
|
11
|
+
external_key,
|
12
|
+
order.id.to_s,
|
13
|
+
"order_mailer/order_shipped_plain",
|
14
|
+
"order_mailer/order_shipped_html").perform
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Spree
|
2
|
+
User.class_eval do
|
3
|
+
|
4
|
+
has_and_belongs_to_many :bronto_lists, class_name: "Spree::BrontoList", join_table: :spree_bronto_lists_users
|
5
|
+
|
6
|
+
accepts_nested_attributes_for :bronto_lists
|
7
|
+
|
8
|
+
def deliver_password_reset_instructions!(current_store)
|
9
|
+
|
10
|
+
#@edit_password_reset_url = edit_spree_user_password_url(:reset_password_token => token, :host => current_store.url)
|
11
|
+
|
12
|
+
#mail to: user.email, from: from_address, subject: Spree::Store.current.name + ' ' + I18n.t(:subject, :scope => [:devise, :mailer, :reset_password_instructions])
|
13
|
+
|
14
|
+
#Bronto sending
|
15
|
+
#trigger the email directly here.
|
16
|
+
store_code= current_store.code
|
17
|
+
token= Spree::BrontoConfiguration.account[store_code]['token']
|
18
|
+
from_email= current_store.mail_from_address
|
19
|
+
from_name= Spree::BrontoConfiguration.account[store_code]['from_name']
|
20
|
+
reply_email= current_store.mail_from_address
|
21
|
+
email_options={:fromEmail =>from_email,:fromName => from_name, :replyEmail => reply_email}
|
22
|
+
|
23
|
+
user_order=orders.select{|o| o.state='complete'}.last
|
24
|
+
|
25
|
+
message_name= Spree::BrontoConfiguration.account[current_store.code]['password_reset']
|
26
|
+
|
27
|
+
attributes = {:First_Name => user_order.ship_address.firstname} unless !user_order
|
28
|
+
attributes = {:First_Name => user_order.ship_address.lastname} unless !user_order
|
29
|
+
|
30
|
+
attributes[:SENDTIME__CONTENT1] = reset_password_token
|
31
|
+
attributes[:SENDTIME__CONTENT2] = reset_password_token
|
32
|
+
|
33
|
+
begin
|
34
|
+
communication = BrontoIntegration::Communication.new(token)
|
35
|
+
communication.trigger_delivery_by_id(message_name,email,'transactional','html',attributes,email_options)
|
36
|
+
|
37
|
+
rescue => exception
|
38
|
+
begin #handle the transactional contact in case the message is not approved for transactional.
|
39
|
+
contact = BrontoIntegration::Contact.new(token)
|
40
|
+
contact.update_status(email,'active')
|
41
|
+
communication.trigger_delivery_by_id(message_name,email,'triggered','html',attributes,email_options)
|
42
|
+
rescue => exception
|
43
|
+
raise exception
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,5 @@
|
|
1
|
+
Deface::Override.new(:virtual_path => "spree/admin/shared/sub_menu/_configuration",
|
2
|
+
:name => "bronto_admin_configurations_menu",
|
3
|
+
:insert_bottom => "[data-hook='admin_configurations_sidebar_menu']",
|
4
|
+
:text => "<%= configurations_sidebar_menu_item Spree.t('bronto.lists_admin'), admin_bronto_lists_path %>",
|
5
|
+
:disabled => false)
|
@@ -0,0 +1,6 @@
|
|
1
|
+
Deface::Override.new(
|
2
|
+
:virtual_path => "spree/orders/edit",
|
3
|
+
:name => "bronto_cart_recovery_tags",
|
4
|
+
:insert_after => "[data-hook='cart_container']",
|
5
|
+
:partial => "spree/shared/bronto_tags",
|
6
|
+
:disabled => Spree::BrontoConfiguration.account['disable_cart_recovery'])
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<script type='text/template' id='variant_autocomplete_template'>
|
2
|
+
<div class='variant-autocomplete-item media'>
|
3
|
+
<figure class='variant-image media-left'>
|
4
|
+
<span class="thumbnail no-marginb">
|
5
|
+
{{#if variant.image }}
|
6
|
+
<img src='{{variant.image}}' />
|
7
|
+
{{ else }}
|
8
|
+
<img src='<%= image_path("noimage/mini.png") %>' />
|
9
|
+
{{/if}}
|
10
|
+
</span>
|
11
|
+
</figure>
|
12
|
+
|
13
|
+
<div class='variant-details media-body'>
|
14
|
+
<h5 class="variant-name media-heading">{{variant.name}}</h5>
|
15
|
+
{{#if variant.option_values}}
|
16
|
+
{{#each variant.option_values}}
|
17
|
+
<strong>{{this.option_type_presentation}}:</strong> {{this.presentation}}<br/>
|
18
|
+
{{/each}}
|
19
|
+
{{/if}}
|
20
|
+
<strong><%= Spree.t(:sku) %>:</strong> {{variant.sku}}
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
</script>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<%= render :partial => "spree/admin/bronto_lists/retrieve_lists", :formats => :js %>
|
2
|
+
|
3
|
+
<%= f.field_container :title do %>
|
4
|
+
<%= f.label :title, Spree.t("bronto.title") %> <span class="required">*</span><br />
|
5
|
+
<%= f.text_field :title, :class => 'fullwidth title' %>
|
6
|
+
<%= f.error_message_on :title %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<div id="lists">
|
10
|
+
<%= f.field_container :list_id do %>
|
11
|
+
<%= f.label :list_id, Spree.t("bronto.list_id") %> <span class="required">*</span><br />
|
12
|
+
<%= f.text_field :list_id %>
|
13
|
+
<%= button_tag Spree.t("bronto.retrieve_from_bronto"), :id => "retrieve_bronto_list", :type => "button" %>
|
14
|
+
<%= f.error_message_on :list_id %>
|
15
|
+
<% end %>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
<%= f.field_container :visible do %>
|
19
|
+
<%= f.label :visible, Spree.t("bronto.visible") %> <span class="required">*</span><br />
|
20
|
+
|
21
|
+
<%= f.radio_button(:visible, true ) %>
|
22
|
+
<%= Spree.t("yes") %>
|
23
|
+
|
24
|
+
<%= f.radio_button(:visible, false ) %>
|
25
|
+
<%= Spree.t("no") %>
|
26
|
+
|
27
|
+
<%= f.error_message_on :visible %>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
<%= f.field_container :subscribe_all_new_users do %>
|
31
|
+
<%= f.label :subscribe_all_new_users, Spree.t("bronto.subscribe_all_new_users") %> <span class="required">*</span><br />
|
32
|
+
|
33
|
+
<%= f.radio_button(:subscribe_all_new_users, true ) %>
|
34
|
+
<%= Spree.t("yes") %>
|
35
|
+
|
36
|
+
<%= f.radio_button(:subscribe_all_new_users, false ) %>
|
37
|
+
<%= Spree.t("no") %>
|
38
|
+
|
39
|
+
<%= f.error_message_on :subscribe_all_new_users %>
|
40
|
+
<% end %>
|
41
|
+
|
42
|
+
|
43
|
+
<%= f.field_container :store_id do %>
|
44
|
+
<%= f.label :store_id, Spree.t("bronto.store_id") %> <span class="required">*</span><br />
|
45
|
+
|
46
|
+
<%= f.collection_select :store_id, @stores, :id, :name, {}, { :multiple => false, :class => "select2" } %>
|
47
|
+
|
48
|
+
<%= f.error_message_on :store_id %>
|
49
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= select_tag 'bronto_list[list_id]', options_for_select(@lists, @list_id) -%>
|
@@ -0,0 +1 @@
|
|
1
|
+
$('#bronto_list_list_id').replaceWith('<%= escape_javascript(render partial: 'spree/admin/bronto_lists/get_lists', formats: [:html], handlers: [:erb]) %>');
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
$(document).ready(
|
3
|
+
function() {
|
4
|
+
$('#retrieve_bronto_list').click(function () {
|
5
|
+
$.getScript('<%= get_lists_admin_bronto_lists_path %>.js?list_id=' + $('#bronto_list_list_id').val() + '&store_id=' + $('#bronto_list_store_id').val())
|
6
|
+
});
|
7
|
+
$('#bronto_list_store_id').change(function () {
|
8
|
+
$.getScript('<%= get_lists_admin_bronto_lists_path %>.js?list_id=' + $('#bronto_list_list_id').val() + '&store_id=' + $('#bronto_list_store_id').val())
|
9
|
+
});
|
10
|
+
});
|
11
|
+
</script>
|
12
|
+
|
13
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
<h1><%= Spree.t("bronto.editing") %></h1>
|
4
|
+
|
5
|
+
<%= render :partial => 'spree/admin/shared/error_messages', :locals => { :target => @bronto_list } %>
|
6
|
+
<%= form_for(@bronto_list, :url => object_url, :html => { :method => :put }) do |f| %>
|
7
|
+
<%= render :partial => "form", :locals => { :f => f } %>
|
8
|
+
<p>
|
9
|
+
<%=submit_tag Spree.t("update")%>
|
10
|
+
</p>
|
11
|
+
<% end %>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
<div class='toolbar'>
|
4
|
+
<ul class='actions'>
|
5
|
+
<li>
|
6
|
+
<%= button_link_to Spree.t("bronto.new_list"), new_object_url, :icon => 'add' %>
|
7
|
+
</li>
|
8
|
+
</ul>
|
9
|
+
<br class='clear' />
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<h1><%= Spree.t("exact_target.lists") %></h1>
|
13
|
+
|
14
|
+
<table class="index">
|
15
|
+
<thead data-hook="admin_bronto_lists_index_headers">
|
16
|
+
<th><%= Spree.t("bronto.title") %></th>
|
17
|
+
<th><%= Spree.t("bronto.list_id") %></th>
|
18
|
+
<th><%= Spree.t("bronto.subscribe_all_new_users") %></th>
|
19
|
+
<th><%= Spree.t("bronto.visible") %></th>
|
20
|
+
<th data-hook="admin_bronto_lists_index_header_actions"></th>
|
21
|
+
</thead>
|
22
|
+
<tbody>
|
23
|
+
<% @bronto_lists.each do |bronto_list|%>
|
24
|
+
<tr data-hook="admin_exact_target_lists_index_rows" id="<%= dom_id bronto_list %>">
|
25
|
+
<%- locals = {:exact_target_list => bronto_list} -%>
|
26
|
+
|
27
|
+
<td width="140px"><%= bronto_list.title %></td>
|
28
|
+
<td width="120px"><%= bronto_list.list_id %></td>
|
29
|
+
<td width="40px"><%= bronto_list.subscribe_all_new_users.to_s.titleize %></td>
|
30
|
+
<td width="40px"><%= bronto_list.visible.to_s.titleize %></td>
|
31
|
+
<td data-hook="admin_bronto_lists_index_row_actions" width="140px">
|
32
|
+
<%= link_to_edit bronto_list %>
|
33
|
+
<%= link_to_delete bronto_list %>
|
34
|
+
</td>
|
35
|
+
</tr>
|
36
|
+
<% end %>
|
37
|
+
</tbody>
|
38
|
+
</table>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
|
2
|
+
<h1><%= Spree.t("bronto.new_list") %></h1>
|
3
|
+
|
4
|
+
<%= render :partial => 'spree/admin/shared/error_messages', :locals => { :target => @bronto_list } %>
|
5
|
+
|
6
|
+
<%= form_for [:admin,@bronto_list], :html => { :multipart => true } do |f| %>
|
7
|
+
<%= render :partial => "form", :locals => { :f => f } %>
|
8
|
+
<p>
|
9
|
+
<%= submit_tag Spree.t("create") %>
|
10
|
+
</p>
|
11
|
+
<% end %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<div class="">
|
2
|
+
|
3
|
+
<h3><%= t("bronto.my_newsletters") %></h3>
|
4
|
+
|
5
|
+
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @user } %>
|
6
|
+
|
7
|
+
<%= form_for(@user, :url => user_path(@user), :html => { :method => :put, :class => "account-summary well" }) do |f| %>
|
8
|
+
<table style="text-align: left">
|
9
|
+
<tr>
|
10
|
+
<th width="250px"><%= t('name') %></th>
|
11
|
+
<th><%= t('bronto.subscribed') %></th>
|
12
|
+
</tr>
|
13
|
+
<%= render :partial => "spree/bronto_lists/form", @collection => @bronto_lists, :locals => { :f => f } %>
|
14
|
+
</table>
|
15
|
+
<br/>
|
16
|
+
<%= button_tag :class => 'btn btn-submit' do %>
|
17
|
+
<%= t("bronto.update_subscriptions") %>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% unless @bronto_lists.nil? %>
|
2
|
+
<% @bronto_lists.each do |bronto_list| %>
|
3
|
+
<tr>
|
4
|
+
<td><%= bronto_list.title %></td>
|
5
|
+
<td>
|
6
|
+
<label class="sub">
|
7
|
+
<%= radio_button_tag("user[bronto_list_attributes][#{bronto_list.id}]", true, @user.bronto_lists.include?(bronto_list) ) %>
|
8
|
+
<%= t("yes") %>
|
9
|
+
</label>
|
10
|
+
<label class="sub">
|
11
|
+
<%= radio_button_tag("user[bronto_list_attributes][#{bronto_list.id}]", false, !@user.bronto_lists.include?(bronto_list) ) %>
|
12
|
+
<%= t("no") %>
|
13
|
+
</label>
|
14
|
+
</td>
|
15
|
+
</tr>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% unless @bronto_lists.blank? %>
|
2
|
+
<%- @subscribe = @order.user.nil? ? true : !@order.user.bronto_lists.include?(@bronto_lists.first.id) -%>
|
3
|
+
<p class="address_box" id="snewsletters" >
|
4
|
+
<%= label_tag "Opt-in to our newsletter:" %>
|
5
|
+
<%= radio_button_tag("bronto_list[#{@bronto_lists.first.id}]", true, @subscribe, :style => "width:20px;") %>
|
6
|
+
<span><%= t("yes") %> </span>
|
7
|
+
|
8
|
+
<%= radio_button_tag("bronto_list[#{@bronto_lists.first.id}]", false, !@subscribe, :style => "width:20px;") %>
|
9
|
+
<span><%= t("no") %></span>
|
10
|
+
<span class="note">(sent twice a month, includes unadvertised discounts)</span>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<% end %>
|
@@ -0,0 +1,69 @@
|
|
1
|
+
<% tagkey= Spree::BrontoConfiguration.account[current_store.code]['tagkey'] unless !@order %>
|
2
|
+
|
3
|
+
<script type="text/javascript">
|
4
|
+
var _bsw = _bsw || [];
|
5
|
+
_bsw.push(['_bswId', '<%= tagkey %>']);
|
6
|
+
(function() {
|
7
|
+
var bsw = document.createElement('script'); bsw.type = 'text/javascript'; bsw.async = true;
|
8
|
+
bsw.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'js.bronto.com/s/b.min.js';
|
9
|
+
var t = document.getElementsByTagName('script')[0]; t.parentNode.insertBefore(bsw, t);
|
10
|
+
})();
|
11
|
+
</script>
|
12
|
+
<%
|
13
|
+
if !!@order && @order.state !='complete' # cart review or @order review page
|
14
|
+
cartItems="["
|
15
|
+
@order.line_items.each do |item|
|
16
|
+
cartItems += '{"other": null'
|
17
|
+
cartItems += ', "imageUrl": "' + ERB::Util.html_escape(@order.line_items.first.product.images.first.attachment.url(:product))
|
18
|
+
cartItems += '", "unitPrice": ' + item.price.to_s
|
19
|
+
cartItems += ', "sku": "' + item.variant.sku
|
20
|
+
cartItems += '", "category": "'
|
21
|
+
cartItems += '", "description": "'
|
22
|
+
cartItems += '", "productUrl": "' + 'http://www.' + current_store.name.downcase + '/products/' + item.product.slug
|
23
|
+
cartItems += '", "name": "' + ERB::Util.html_escape(item.product.name)
|
24
|
+
cartItems += '", "quantity": ' + item.quantity.to_s
|
25
|
+
cartItems += ', "salePrice": 0'
|
26
|
+
cartItems += ', "totalPrice": ' + (item.price * item.quantity).to_f.to_s
|
27
|
+
cartItems += ' },'
|
28
|
+
end
|
29
|
+
cartItems = cartItems.gsub(/\,\z/,'') + ']'
|
30
|
+
|
31
|
+
%>
|
32
|
+
<script type="text/javascript">
|
33
|
+
// create a data object with information of the product added
|
34
|
+
var braCart = {
|
35
|
+
"customerCartId": "<%= "#{"QA-" if request.server_name =~ /^(dev.|staging.|local.)/ }#{@order.number}" %>",
|
36
|
+
"email": "<%= @order.email %>",
|
37
|
+
"grandTotal": <%= @order.total.to_s %>,
|
38
|
+
"subtotal": <%= @order.item_total.to_s %>,
|
39
|
+
"discountAmount": <%= (100*@order.line_item_adjustments.promotion.eligible.map{|t| t.amount}.sum).to_i/100.00 %>,
|
40
|
+
"url": "http://www.<%= current_store.name.downcase %>/cart",
|
41
|
+
"currency": "USD",
|
42
|
+
"taxAmount": <%= (100*@order.line_item_adjustments.tax.eligible.map{|t| t.amount}.sum).to_i/100.00 %>,
|
43
|
+
"lineItems": <%= cartItems.html_safe %>
|
44
|
+
};
|
45
|
+
</script>
|
46
|
+
|
47
|
+
<% elsif !!@order && @order.state=='complete' # The bronto conversion tracking
|
48
|
+
orderItems="["
|
49
|
+
@order.line_items.each do |item|
|
50
|
+
orderItems += '{"item_id": "' + item.id.to_s + '", "amount": "' + item.price.to_s + '", "name": "' + ERB::Util.html_escape(item.product.name) + '"'
|
51
|
+
orderItems += ', "quantity": ' + item.quantity.to_s + ', "url": "http://www.' + @order.store.name + '/' + item.product.slug + '" },'
|
52
|
+
end
|
53
|
+
orderItems = orderItems.gsub(/\,\z/,'') + ']'
|
54
|
+
%>
|
55
|
+
<script type="text/javascript">
|
56
|
+
// create a data object with information of the product added
|
57
|
+
var braOrder = {
|
58
|
+
"order_id": "<%= "#{"QA-" if request.server_name =~ /^(dev.|staging.|local.)/ }#{@order.number}" %>",
|
59
|
+
"email": "<%= @order.email %>",
|
60
|
+
"date": "<%= @order.completed_at.iso8601() %>",
|
61
|
+
"items": <%= orderItems %>
|
62
|
+
};
|
63
|
+
|
64
|
+
//bta.addOrder(braOrder)
|
65
|
+
</script>
|
66
|
+
|
67
|
+
|
68
|
+
<% end %>
|
69
|
+
|
data/bin/rails
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
2
|
+
|
3
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
4
|
+
ENGINE_PATH = File.expand_path('../../lib/spree_bronto/engine', __FILE__)
|
5
|
+
|
6
|
+
require 'rails/all'
|
7
|
+
require 'rails/engine/commands'
|