spree_bronto 3.pre.0.pre.stable → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/spree/checkout_controller_decorator.rb +0 -14
- data/app/controllers/spree/users_controller_decorator.rb +1 -18
- data/app/mailers/spree/order_mailer/_order_shipped_html.html.erb +6 -6
- data/app/mailers/spree/order_mailer/_order_shipped_plain.erb +6 -6
- data/app/models/spree/order_decorator.rb +3 -2
- data/app/models/spree/user_decorator.rb +0 -42
- data/app/overrides/decorate_account_my_orders.rb +1 -1
- data/app/overrides/decorate_bronto_list_subscribe.rb +1 -1
- data/app/views/spree/bronto_lists/_edit.html.erb +7 -8
- data/app/views/spree/bronto_lists/_signup.html.erb +2 -4
- data/app/views/spree/shared/_bronto_tags.html.erb +3 -3
- data/config/locales/en.yml +1 -4
- data/config/routes.rb +1 -11
- data/lib/delayed_send.rb +1 -1
- data/lib/delayed_subscriber_add.rb +9 -9
- data/lib/delayed_subscriber_delete.rb +12 -12
- data/lib/delayed_subscriber_update.rb +1 -1
- data/lib/delayed_trigger.rb +1 -1
- data/lib/spree_bronto/engine.rb +2 -6
- data/spree_bronto.gemspec +2 -3
- metadata +18 -11
- data/app/controllers/spree/home_controller_decorator.rb +0 -120
- data/app/controllers/spree/lists.rb +0 -152
- data/app/controllers/spree/orders_controller_decorator.rb +0 -56
- data/app/mailers/spree/user_mailer/_password_reset_instructions.html.erb +0 -9
- data/app/mailers/spree/user_mailer_decorator.rb +0 -13
- data/app/models/spree/shipment_handler_decorator.rb +0 -17
- data/lib/delayed_simple_send.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce7cfe85f900f8971fd940dbdcdd21a5dd17af58
|
4
|
+
data.tar.gz: e42050af673cd1204155fc2d6676c1304a615e08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20f510e2cfdecae46fe16b178c0e26833c4c63d56299a06076e5c4da68b5e5fbf2b5806f287e8052a0de3042dea9a9a7c20817708367ab26620b6a42f1525367
|
7
|
+
data.tar.gz: 34151b42e4aa94ed3d5dfa93b4348ac3b90a5df2666c53dbbcca9c7d339d610ae77da9ef749ad7d9dcad5bf055c5b7f61c6ba84f6452cd3b9b21372b3f63db17
|
@@ -1,6 +1,4 @@
|
|
1
1
|
Spree::CheckoutController.class_eval do
|
2
|
-
include Spree::Lists
|
3
|
-
before_action :check_newsletter
|
4
2
|
|
5
3
|
def load_order_with_lock
|
6
4
|
@order = current_order(lock: true)
|
@@ -8,16 +6,4 @@ Spree::CheckoutController.class_eval do
|
|
8
6
|
redirect_to spree.cart_path and return unless @order
|
9
7
|
end
|
10
8
|
|
11
|
-
private
|
12
|
-
def check_newsletter
|
13
|
-
if params['bronto_list']
|
14
|
-
params['bronto_list'].each do |k,v|
|
15
|
-
list=Spree::BrontoList.find(k)
|
16
|
-
if k && v && @order.email
|
17
|
-
subscribe_to_list(@order.email, list)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
9
|
end
|
@@ -1,27 +1,10 @@
|
|
1
1
|
Spree::UsersController.class_eval do
|
2
|
-
include Spree::Lists
|
3
2
|
|
4
|
-
|
5
|
-
before_action :check_newsletter
|
3
|
+
before_action :load_bronto_lists
|
6
4
|
|
7
5
|
private
|
8
6
|
def load_bronto_lists
|
9
7
|
@bronto_lists=current_store.bronto_lists
|
10
8
|
end
|
11
9
|
|
12
|
-
def check_newsletter
|
13
|
-
if params['user'] && params['user']['bronto_list_attributes']
|
14
|
-
params['user']['bronto_list_attributes'].each do|k,v|
|
15
|
-
list=Spree::BrontoList.find(k)
|
16
|
-
if k && @user && v=="true"
|
17
|
-
subscribe_to_list(@user, list)
|
18
|
-
end
|
19
|
-
|
20
|
-
if k && @user && v=="false"
|
21
|
-
unsubscribe_from_list(@user, list)
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
10
|
end
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
<p>
|
4
4
|
<strong>Your tracking details:</strong><br />
|
5
|
-
Package ID: <%= order.
|
6
|
-
Sent date: <%= order.
|
7
|
-
Shipped via: <%= order.
|
8
|
-
<%unless order.
|
9
|
-
<%= order.
|
5
|
+
Package ID: <%= order.shipment.number %><br />
|
6
|
+
Sent date: <%= order.shipment.updated_at.strftime("%B %d %Y at %I:%M %p") %><br />
|
7
|
+
Shipped via: <%= order.shipment.shipping_method.name %><br /><br />
|
8
|
+
<%unless order.shipment.shipping_method.blank? || order.shipment.tracking.blank? %>
|
9
|
+
<%= order.shipment.shipping_method.name%> Tracking Number: <%= order.shipment.tracking %><br />
|
10
10
|
To track your package, go to:<br />
|
11
|
-
<a href="<%= order.
|
11
|
+
<a href="<%= order.shipment.shipping_method_trackurl+order.shipment.tracking %>"><%=order.shipment.shipping_method.name %> Tracking</a>
|
12
12
|
<% end %>
|
13
13
|
</p>
|
14
14
|
|
@@ -1,15 +1,15 @@
|
|
1
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
2
|
|
3
3
|
Your tracking details:
|
4
|
-
Package ID: <%= order.
|
5
|
-
Sent date: <%= order.
|
6
|
-
Shipped via: <%= order.
|
4
|
+
Package ID: <%= order.shipment.number %>
|
5
|
+
Sent date: <%= order.shipment.updated_at.strftime("%B %d %Y at %I:%M %p") %>
|
6
|
+
Shipped via: <%= order.shipment.shipping_method.name %>
|
7
7
|
|
8
|
-
<%unless order.
|
9
|
-
<%= order.
|
8
|
+
<%unless order.shipment.shipping_method.blank? || order.shipment.tracking.blank? %>
|
9
|
+
<%= order.shipment.shipping_method.name%> Tracking Number: <%= order.shipment.tracking %>
|
10
10
|
|
11
11
|
To track your package, go to:
|
12
|
-
<%= order.
|
12
|
+
<%= order.shipment.shipping_method.trackurl+order.shipment.tracking%>
|
13
13
|
<% end %>
|
14
14
|
|
15
15
|
Here are the details of the order we received on <%= order.completed_at.strftime("%B %d %Y at %I:%M %p") %>.
|
@@ -1,4 +1,5 @@
|
|
1
|
-
Spree
|
1
|
+
module Spree
|
2
|
+
Order.class_eval do
|
2
3
|
|
3
4
|
def deliver_order_confirmation_email
|
4
5
|
#OrderMailer.confirm_email(id).deliver_later # we replace OrderMailer with DelayedSend
|
@@ -26,5 +27,5 @@ Spree::Order.class_eval do
|
|
26
27
|
"order_mailer/order_cancel_plain",
|
27
28
|
"order_mailer/order_cancel_html").perform
|
28
29
|
end
|
29
|
-
|
30
|
+
end
|
30
31
|
end
|
@@ -5,47 +5,5 @@ module Spree
|
|
5
5
|
|
6
6
|
accepts_nested_attributes_for :bronto_lists
|
7
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
8
|
end
|
51
9
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Deface::Override.new(
|
2
2
|
:virtual_path => "spree/users/show",
|
3
3
|
:name => "bronto_lists_edit_form",
|
4
|
-
:
|
4
|
+
:insert_after => "[data-hook='account_my_orders']",
|
5
5
|
:partial => "spree/bronto_lists/edit",
|
6
6
|
:disabled => false)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Deface::Override.new(
|
2
2
|
:virtual_path => "spree/checkout/_address",
|
3
3
|
:name => "bronto_list_subscribe",
|
4
|
-
:
|
4
|
+
:insert_after => "[data-hook='billing_fieldset_wrapper']",
|
5
5
|
:partial => "spree/bronto_lists/signup",
|
6
6
|
:disabled => false)
|
@@ -1,10 +1,11 @@
|
|
1
|
-
<div class="">
|
2
|
-
|
3
|
-
<h3><%= t("bronto.my_newsletters") %></h3>
|
1
|
+
<div class="address_box">
|
4
2
|
|
5
3
|
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @user } %>
|
6
4
|
|
7
|
-
<%= form_for(@user, :url => user_path(@user), :html => { :method => :put
|
5
|
+
<%= form_for(@user, :url => user_path(@user), :html => { :method => :put }) do |f| %>
|
6
|
+
|
7
|
+
<h2><%= t("bronto.my_newsletters") %></h2>
|
8
|
+
<br/>
|
8
9
|
<table style="text-align: left">
|
9
10
|
<tr>
|
10
11
|
<th width="250px"><%= t('name') %></th>
|
@@ -13,9 +14,7 @@
|
|
13
14
|
<%= render :partial => "spree/bronto_lists/form", @collection => @bronto_lists, :locals => { :f => f } %>
|
14
15
|
</table>
|
15
16
|
<br/>
|
16
|
-
<%=
|
17
|
-
<%= t("bronto.update_subscriptions") %>
|
17
|
+
<%=button_tag t("bronto.update_subscriptions")%>
|
18
18
|
<% end %>
|
19
|
-
|
20
|
-
|
19
|
+
<br/>
|
21
20
|
</div>
|
@@ -1,13 +1,11 @@
|
|
1
1
|
<% unless @bronto_lists.blank? %>
|
2
2
|
<%- @subscribe = @order.user.nil? ? true : !@order.user.bronto_lists.include?(@bronto_lists.first.id) -%>
|
3
|
-
<p
|
4
|
-
|
3
|
+
<p id="snewsletters" class="field">
|
4
|
+
<label>Opt-in to our newsletter:</label>
|
5
5
|
<%= radio_button_tag("bronto_list[#{@bronto_lists.first.id}]", true, @subscribe, :style => "width:20px;") %>
|
6
6
|
<span><%= t("yes") %> </span>
|
7
7
|
|
8
8
|
<%= radio_button_tag("bronto_list[#{@bronto_lists.first.id}]", false, !@subscribe, :style => "width:20px;") %>
|
9
9
|
<span><%= t("no") %></span>
|
10
|
-
<span class="note">(sent twice a month, includes unadvertised discounts)</span>
|
11
10
|
</p>
|
12
|
-
|
13
11
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% tagkey= Spree::BrontoConfiguration.account[
|
1
|
+
<% tagkey= Spree::BrontoConfiguration.account[@order.store.code]['tagkey'] unless !@order %>
|
2
2
|
|
3
3
|
<script type="text/javascript">
|
4
4
|
var _bsw = _bsw || [];
|
@@ -19,7 +19,7 @@
|
|
19
19
|
cartItems += ', "sku": "' + item.variant.sku
|
20
20
|
cartItems += '", "category": "'
|
21
21
|
cartItems += '", "description": "'
|
22
|
-
cartItems += '", "productUrl": "' + 'http://www.' +
|
22
|
+
cartItems += '", "productUrl": "' + 'http://www.' + @order.store.name.downcase + '/products/' + item.product.slug
|
23
23
|
cartItems += '", "name": "' + ERB::Util.html_escape(item.product.name)
|
24
24
|
cartItems += '", "quantity": ' + item.quantity.to_s
|
25
25
|
cartItems += ', "salePrice": 0'
|
@@ -37,7 +37,7 @@
|
|
37
37
|
"grandTotal": <%= @order.total.to_s %>,
|
38
38
|
"subtotal": <%= @order.item_total.to_s %>,
|
39
39
|
"discountAmount": <%= (100*@order.line_item_adjustments.promotion.eligible.map{|t| t.amount}.sum).to_i/100.00 %>,
|
40
|
-
"url": "http://www.<%=
|
40
|
+
"url": "http://www.<%= @order.store.name.downcase %>/orders/new",
|
41
41
|
"currency": "USD",
|
42
42
|
"taxAmount": <%= (100*@order.line_item_adjustments.tax.eligible.map{|t| t.amount}.sum).to_i/100.00 %>,
|
43
43
|
"lineItems": <%= cartItems.html_safe %>
|
data/config/locales/en.yml
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
|
4
4
|
en:
|
5
5
|
spree:
|
6
|
-
subscription_sent: Signed up
|
7
|
-
subscription_notsent: Singup failed
|
8
6
|
bronto:
|
9
7
|
lists_admin: Bronto Lists
|
10
8
|
manage_settings: Manage Bronto mailing lists made available to Spree users
|
@@ -23,5 +21,4 @@ en:
|
|
23
21
|
update_subscriptions: Update Subscriptions
|
24
22
|
subscribed: Subscribed?
|
25
23
|
subscribe_question: Would you like to subscribe to any of our newsletters?
|
26
|
-
store_id: Web Store
|
27
|
-
no_such_list: This newsletter does not exist
|
24
|
+
store_id: Web Store
|
data/config/routes.rb
CHANGED
@@ -6,14 +6,4 @@ Spree::Core::Engine.routes.append do
|
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
9
|
-
|
10
|
-
resources :orders, :except => [:index, :new, :create, :destroy] do
|
11
|
-
patch :subscribe, :on => :member
|
12
|
-
end
|
13
|
-
|
14
|
-
post "/subscribenewsletter", :to => 'home#subscribenewsletter'
|
15
|
-
post "/subscribecampaign", :to => 'home#subscribecampaign'
|
16
|
-
post "/subscribecampaign_with_ops", :to => 'home#subscribecampaign_with_ops'
|
17
|
-
|
18
|
-
end
|
19
|
-
|
9
|
+
end
|
data/lib/delayed_send.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
class DelayedSubscriberAdd < Struct.new(:store_code, :user, :list, :ops)
|
2
3
|
def perform
|
3
4
|
|
4
5
|
if list.nil? || !user
|
@@ -25,14 +26,13 @@ DelayedSubscriberAdd = Struct.new(:store_code, :user, :list, :ops) do
|
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
unless user.is_a? String
|
30
|
+
begin
|
31
|
+
user.bronto_lists << list
|
32
|
+
user.save!
|
33
|
+
rescue
|
34
|
+
end
|
35
|
+
end
|
36
36
|
|
37
37
|
end
|
38
38
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
DelayedSubscriberDelete
|
1
|
+
class DelayedSubscriberDelete < Struct.new(:store_code, :user, :list)
|
2
2
|
def perform
|
3
3
|
if list.nil? || !user
|
4
4
|
subscriber_id = -1
|
@@ -19,17 +19,17 @@ DelayedSubscriberDelete = Struct.new(:store_code, :user, :list) do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
unless user.is_a? String # update exact_target_lists
|
23
|
+
begin
|
24
|
+
list_del=user.bronto_lists.select{|l| l.id== list.id}
|
25
|
+
if list_del.length>0
|
26
|
+
user.bronto_lists.delete(list_del)
|
27
|
+
end
|
28
|
+
user.save!
|
29
|
+
rescue
|
30
|
+
#raise exception
|
31
|
+
end
|
32
|
+
end
|
33
33
|
|
34
34
|
end
|
35
35
|
end
|
data/lib/delayed_trigger.rb
CHANGED
data/lib/spree_bronto/engine.rb
CHANGED
@@ -16,12 +16,8 @@ module SpreeBronto
|
|
16
16
|
Dir.glob(File.join(File.dirname(__FILE__), '../../lib/bronto_integration/bronto_integration.rb')) do |c|
|
17
17
|
Rails.configuration.cache_classes ? require(c) : load(c)
|
18
18
|
end
|
19
|
-
|
20
|
-
|
21
|
-
#end
|
22
|
-
Dir.glob(File.join(File.dirname(__FILE__), '../../lib/delayed_*.rb')) do |c|
|
23
|
-
require(c)
|
24
|
-
#Rails.configuration.cache_classes ? require(c) : load(c)
|
19
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../../lib/delayed*.rb')) do |c|
|
20
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
25
21
|
end
|
26
22
|
end
|
27
23
|
|
data/spree_bronto.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.platform = Gem::Platform::RUBY
|
4
4
|
s.name = 'spree_bronto'
|
5
|
-
s.version = '3
|
5
|
+
s.version = '3.0.0'
|
6
6
|
s.summary = 'Integrate Bronto email server and cart recovery into Spree Ecommerce platform'
|
7
7
|
s.description = 'Integrate Bronto email server and cart recovery into Spree Ecommerce platform'
|
8
8
|
s.required_ruby_version = '>= 2.0.0'
|
@@ -16,8 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.require_path = 'lib'
|
17
17
|
s.requirements << 'none'
|
18
18
|
|
19
|
-
|
20
|
-
#s.add_dependency 'spree_core'
|
19
|
+
s.add_dependency 'spree_core', '~> 3.0.0'
|
21
20
|
|
22
21
|
s.add_development_dependency 'capybara', '~> 2.4'
|
23
22
|
s.add_development_dependency 'coffee-rails'
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_bronto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Albert Liu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: spree_core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: capybara
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,9 +184,6 @@ files:
|
|
170
184
|
- app/assets/stylesheets/spree/frontend/spree_bronto.css
|
171
185
|
- app/controllers/spree/admin/bronto_lists_controller.rb
|
172
186
|
- app/controllers/spree/checkout_controller_decorator.rb
|
173
|
-
- app/controllers/spree/home_controller_decorator.rb
|
174
|
-
- app/controllers/spree/lists.rb
|
175
|
-
- app/controllers/spree/orders_controller_decorator.rb
|
176
187
|
- app/controllers/spree/users_controller_decorator.rb
|
177
188
|
- app/mailers/spree/order_mailer/_order_cancel_html.html.erb
|
178
189
|
- app/mailers/spree/order_mailer/_order_cancel_plain.erb
|
@@ -182,13 +193,10 @@ files:
|
|
182
193
|
- app/mailers/spree/order_mailer/_order_details_plain.erb
|
183
194
|
- app/mailers/spree/order_mailer/_order_shipped_html.html.erb
|
184
195
|
- app/mailers/spree/order_mailer/_order_shipped_plain.erb
|
185
|
-
- app/mailers/spree/user_mailer/_password_reset_instructions.html.erb
|
186
|
-
- app/mailers/spree/user_mailer_decorator.rb
|
187
196
|
- app/models/spree/bronto_configuration.rb
|
188
197
|
- app/models/spree/bronto_list.rb
|
189
198
|
- app/models/spree/order_decorator.rb
|
190
199
|
- app/models/spree/shipment_decorator.rb
|
191
|
-
- app/models/spree/shipment_handler_decorator.rb
|
192
200
|
- app/models/spree/store_decorator.rb
|
193
201
|
- app/models/spree/user_decorator.rb
|
194
202
|
- app/overrides/decorate_account_my_orders.rb
|
@@ -219,7 +227,6 @@ files:
|
|
219
227
|
- lib/bronto_integration/bronto_integration/contact.rb
|
220
228
|
- lib/bronto_integration/bronto_integration/order.rb
|
221
229
|
- lib/delayed_send.rb
|
222
|
-
- lib/delayed_simple_send.rb
|
223
230
|
- lib/delayed_subscriber_add.rb
|
224
231
|
- lib/delayed_subscriber_delete.rb
|
225
232
|
- lib/delayed_subscriber_update.rb
|
@@ -244,9 +251,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
244
251
|
version: 2.0.0
|
245
252
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
246
253
|
requirements:
|
247
|
-
- - "
|
254
|
+
- - ">="
|
248
255
|
- !ruby/object:Gem::Version
|
249
|
-
version:
|
256
|
+
version: '0'
|
250
257
|
requirements:
|
251
258
|
- none
|
252
259
|
rubyforge_project:
|
@@ -1,120 +0,0 @@
|
|
1
|
-
Spree::HomeController.class_eval do
|
2
|
-
|
3
|
-
def subscribenewsletter
|
4
|
-
name=params[:name] || ''
|
5
|
-
email=params[:email]
|
6
|
-
receipt=params[:receipt] || ''
|
7
|
-
subject=params[:subject] || 'Customer Record'
|
8
|
-
if receipt.length>0
|
9
|
-
external_key = Spree::BrontoConfiguration.account[current_store.code]["ET_simple_send"]
|
10
|
-
params.delete('action')
|
11
|
-
params.delete('receipt')
|
12
|
-
params.delete('authenticity_token')
|
13
|
-
params.delete('controller')
|
14
|
-
params.delete('subject')
|
15
|
-
params.delete('cc_receipt')
|
16
|
-
the_content=''
|
17
|
-
ks=[]
|
18
|
-
vs=[]
|
19
|
-
params.each do |k,v|
|
20
|
-
ks << k
|
21
|
-
vs << v
|
22
|
-
end
|
23
|
-
the_content = ks.join(',') + '<br/>' + vs.join(',')
|
24
|
-
et_a={:SENDTIME__CONTENT2 => the_content, :SENDTIME__CONTENT1 => subject}
|
25
|
-
#et_a={:SENDTIME__CONTENT2 => 'Name: ' + name +'<br/>Email: ' + email + '<br/>Address: ' + params[:address] + '<br/>City: ' + params[:city] + '<br/>State: ' + params[:state] +'<br/>Zip: ' + params[:zip] +'<br/>Phone: ' + params[:phone] +'<br/>Credentials: ' + params[:credentials]}
|
26
|
-
Delayed::Job.enqueue DelayedSimpleSend.new(current_store.code, receipt, external_key, et_a,'html')
|
27
|
-
cc_receipt= params[:cc_receipt] || ''
|
28
|
-
if cc_receipt.length>0
|
29
|
-
Delayed::Job.enqueue DelayedSimpleSend.new(current_store.code, cc_receipt, external_key, et_a,'html')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
if email.length>0
|
33
|
-
if current_store.code == 'pwb'
|
34
|
-
title='Pets & Products Newsletter'
|
35
|
-
elsif current_store.code == 'he'
|
36
|
-
title='HairEssentials Products Newsletter'
|
37
|
-
else
|
38
|
-
title='Natural Products Newsletter'
|
39
|
-
end
|
40
|
-
campaign= Spree::BrontoList.find_by_title(title)
|
41
|
-
if !!campaign
|
42
|
-
Delayed::Job.enqueue DelayedSubscriberAdd.new(current_store.code, email, campaign, {:First_Name => name})
|
43
|
-
end
|
44
|
-
render :json => ({
|
45
|
-
:success => true,
|
46
|
-
:message => t( :subscription_sent )
|
47
|
-
}).to_json
|
48
|
-
else
|
49
|
-
render :json => ({
|
50
|
-
:success => false,
|
51
|
-
:message => t( :subscription_notsent )
|
52
|
-
}).to_json
|
53
|
-
end
|
54
|
-
#redirect_to "/meetexperts"
|
55
|
-
#render :js =>'alert("Our server temperarily busy, please try again later.")'
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
# sign up compaign flexible form, like the one for newsletter.
|
60
|
-
def subscribecampaign
|
61
|
-
name=params[:name] || ''
|
62
|
-
email=params[:email]
|
63
|
-
campaign_id=params[:campaign_id] || ''
|
64
|
-
if email.length>0
|
65
|
-
campaign=Spree::BrontoList.find_by_list_id(campaign_id)
|
66
|
-
if !!campaign
|
67
|
-
options=cookies[:campaign_options] || '{}'
|
68
|
-
options=Hash[JSON.parse(options).map{|(k,v)| [k.to_sym,v]}]
|
69
|
-
Rails.logger.info "find campaign_options cookie: #{cookies.inspect}"
|
70
|
-
Delayed::Job.enqueue DelayedSubscriberAdd.new(current_store.code, email, campaign, {:First_Name => name})
|
71
|
-
end
|
72
|
-
|
73
|
-
drop_email_key=params[:drop_email_key] || ''
|
74
|
-
unless drop_email_key.blank?
|
75
|
-
Delayed::Job.enqueue DelayedSimpleSend.new(current_store.code, email, drop_email_key, {},'html')
|
76
|
-
end
|
77
|
-
render :json => ({
|
78
|
-
:success => true,
|
79
|
-
:message => t( :subscription_sent )
|
80
|
-
}).to_json
|
81
|
-
else
|
82
|
-
render :json => ({
|
83
|
-
:success => false,
|
84
|
-
:message => t( :subscription_notsent )
|
85
|
-
}).to_json
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
|
91
|
-
# sign up compaign flexible form, like the one for newsletter.
|
92
|
-
def subscribecampaign_with_ops
|
93
|
-
email=params[:email]
|
94
|
-
campaign_id=params[:campaign_id] || ''
|
95
|
-
ops=params[:ops]
|
96
|
-
if email.length>0
|
97
|
-
campaign=Spree::BrontoList.find_by_list_id(campaign_id)
|
98
|
-
if !!campaign
|
99
|
-
Delayed::Job.enqueue DelayedSubscriberAdd.new(current_store.code, email, campaign,ops)
|
100
|
-
end
|
101
|
-
|
102
|
-
drop_email_key=params[:drop_email_key] || ''
|
103
|
-
unless drop_email_key.blank?
|
104
|
-
Delayed::Job.enqueue DelayedSimpleSend.new(current_store.code, email, drop_email_key, {},'html')
|
105
|
-
end
|
106
|
-
|
107
|
-
render :json => ({
|
108
|
-
:success => true,
|
109
|
-
:message => t( :subscription_sent )
|
110
|
-
}).to_json
|
111
|
-
else
|
112
|
-
render :json => ({
|
113
|
-
:success => false,
|
114
|
-
:message => t( :subscription_notsent )
|
115
|
-
}).to_json
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
end
|
@@ -1,152 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module Lists
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
def autosubscribe_list(store)
|
6
|
-
Spree::BrontoList.where(:store_id =>store.id,:subscribe_all_new_users =>true)
|
7
|
-
end
|
8
|
-
|
9
|
-
def create_subscriber(user)
|
10
|
-
if user.is_a? String
|
11
|
-
order = Spree::Order.find_by_email(user, :order => "updated_at desc")
|
12
|
-
store= current_order.store
|
13
|
-
list = autosubscribe_list(store) if checkout
|
14
|
-
else
|
15
|
-
store=current_store
|
16
|
-
list = autosubscribe_list(store)
|
17
|
-
end
|
18
|
-
|
19
|
-
subscribe_to_list(user, list) unless !list
|
20
|
-
|
21
|
-
# synchronize the subscription list from bronto this customer subscribed before registration
|
22
|
-
unless user.is_a? String
|
23
|
-
begin
|
24
|
-
user.reload
|
25
|
-
bronto=Bronto.new(Spree::BrontoConfiguration.account[store.code]['bronto_token'])
|
26
|
-
contact=bronto.read_contacts(user.email,true)
|
27
|
-
list_ids=contact[:list_ids]
|
28
|
-
if list_ids
|
29
|
-
unless list_ids.class == Array
|
30
|
-
list_ids=[list_ids]
|
31
|
-
end
|
32
|
-
list_ids.each do |l|
|
33
|
-
list=Spree::BrontoList.find_by_list_id(l)
|
34
|
-
if !!list && (!user.bronto_lists.map(&:list_id).include? l )
|
35
|
-
user.exact_target_subscriber_id = contact[:id] #seems we do not need this
|
36
|
-
user.bronto_lists << list
|
37
|
-
user.save!
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
rescue
|
43
|
-
# do nothing here at this moment
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
def subscribe_to_list(user, list)
|
50
|
-
|
51
|
-
order=current_order
|
52
|
-
|
53
|
-
pwb_cat=''
|
54
|
-
pwbCat = lambda{|order|
|
55
|
-
iscat=false
|
56
|
-
order.line_items.each do |item|
|
57
|
-
if item.variant.product.taxons.map{|t| t.id}.include?(3002)
|
58
|
-
iscat=true
|
59
|
-
end
|
60
|
-
end
|
61
|
-
if iscat
|
62
|
-
'cat'
|
63
|
-
else
|
64
|
-
'dog'
|
65
|
-
end
|
66
|
-
}
|
67
|
-
if order
|
68
|
-
#logger.debug 'call subscribe_to_list there is a order'
|
69
|
-
store=order.store
|
70
|
-
store_code=store.code
|
71
|
-
pwb_cat= (store_code=="pwb" ? pwbCat.call(order) : '')
|
72
|
-
else
|
73
|
-
store_code=current_store.code
|
74
|
-
pwb_cat=''
|
75
|
-
end
|
76
|
-
#logger.debug '-- found the pwb_cat: ' + pwb_cat
|
77
|
-
Delayed::Job.enqueue( DelayedSubscriberAdd.new(store_code, user, list, {:C_or_D => pwb_cat}), -20 )
|
78
|
-
|
79
|
-
unless user.is_a? String
|
80
|
-
user.bronto_lists << list
|
81
|
-
user.save!
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
def unsubscribe_from_list(user, list)
|
87
|
-
|
88
|
-
store = current_store
|
89
|
-
Delayed::Job.enqueue( DelayedSubscriberDelete.new(store.code, user, list), -20 )
|
90
|
-
|
91
|
-
unless user.is_a? String # update exact_target_lists
|
92
|
-
begin
|
93
|
-
list_del=user.bronto_lists.select{|l| l.id== list.id}
|
94
|
-
if list_del.length>0
|
95
|
-
user.bronto_lists.delete(list_del)
|
96
|
-
end
|
97
|
-
user.save!
|
98
|
-
rescue
|
99
|
-
#raise exception
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
#private
|
106
|
-
#CONTROLLER Actions
|
107
|
-
def get_bronto_lists
|
108
|
-
@bronto_lists = Spree::BrontoList.where(:visible => true)
|
109
|
-
end
|
110
|
-
|
111
|
-
def update_bronto_lists
|
112
|
-
return unless params.key? :bronto_list
|
113
|
-
|
114
|
-
unless @checkout.nil?
|
115
|
-
session[ :bronto_list ] = []
|
116
|
-
end
|
117
|
-
|
118
|
-
@user = @checkout.order.user if @user.nil? && !@checkout.nil?
|
119
|
-
|
120
|
-
params[:bronto_list].each do |id, do_subscribe|
|
121
|
-
do_subscribe = (do_subscribe == "true")
|
122
|
-
list = Spree::BrontoList.find(id)
|
123
|
-
if !@checkout.nil? && do_subscribe
|
124
|
-
session[ :bronto_list ] << id
|
125
|
-
end
|
126
|
-
|
127
|
-
if @user.nil? && !@checkout.nil? #guest checkout
|
128
|
-
if do_subscribe
|
129
|
-
#subscribe
|
130
|
-
subscribe_to_list(@checkout.email, list)
|
131
|
-
else
|
132
|
-
#unsubscribe
|
133
|
-
unsubscribe_from_list(@checkout.email, list)
|
134
|
-
end
|
135
|
-
else #normal checkout
|
136
|
-
if do_subscribe
|
137
|
-
#subscribe
|
138
|
-
unless @user.bronto_lists.include? list
|
139
|
-
subscribe_to_list(@user, list)
|
140
|
-
end
|
141
|
-
else
|
142
|
-
#unsubscribe
|
143
|
-
if @user.bronto_lists.include? list
|
144
|
-
unsubscribe_from_list(@user, list)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
Spree::OrdersController.class_eval do
|
2
|
-
include Spree::Lists
|
3
|
-
|
4
|
-
def subscribe
|
5
|
-
@order = Spree::Order.find_by_number!(params[:id])
|
6
|
-
list = Spree::BrontoList.find( params[ :list ] )
|
7
|
-
unless list.nil?
|
8
|
-
unless @order.user.nil?
|
9
|
-
dest = @order.user
|
10
|
-
else
|
11
|
-
dest = @order.email
|
12
|
-
end
|
13
|
-
unless dest.nil?
|
14
|
-
subscribe_to_list(dest, list)
|
15
|
-
respond_to do |format|
|
16
|
-
format.html {
|
17
|
-
flash[:notice] = Spree.t( :subscription_sent ) unless session[ :return_to ]
|
18
|
-
redirect_to checkout_state_path(@order.state)
|
19
|
-
}
|
20
|
-
format.js {
|
21
|
-
render :json => ({
|
22
|
-
:success => true,
|
23
|
-
:message => Spree.t( :subscription_sent )
|
24
|
-
}).to_json
|
25
|
-
}
|
26
|
-
end
|
27
|
-
else
|
28
|
-
respond_to do |format|
|
29
|
-
format.html {
|
30
|
-
flash[:error] = Spree.t( :subscription_notsent ) unless session[ :return_to ]
|
31
|
-
redirect_to checkout_state_path(@order.state)
|
32
|
-
}
|
33
|
-
format.js {
|
34
|
-
render :json => ({
|
35
|
-
:success => false,
|
36
|
-
:message => Spree.t( :subscription_notsent )
|
37
|
-
}).to_json
|
38
|
-
}
|
39
|
-
end
|
40
|
-
end
|
41
|
-
else
|
42
|
-
respond_to do |format|
|
43
|
-
format.html {
|
44
|
-
flash[:error] = Spree.t( :no_such_list ) unless session[ :return_to ]
|
45
|
-
redirect_to checkout_state_path(@order.state)
|
46
|
-
}
|
47
|
-
format.js {
|
48
|
-
render :json => ({
|
49
|
-
:success => false,
|
50
|
-
:message => Spree.t( :no_such_list )
|
51
|
-
}).to_json
|
52
|
-
}
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,9 +0,0 @@
|
|
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 %>
|
@@ -1,13 +0,0 @@
|
|
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
|
@@ -1,17 +0,0 @@
|
|
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
|
data/lib/delayed_simple_send.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
DelayedSimpleSend = Struct.new(:store_code, :email, :message_name, :attributes, :mail_type) do
|
2
|
-
def perform
|
3
|
-
return if email.blank?
|
4
|
-
begin
|
5
|
-
token= Spree::BrontoConfiguration.account[store_code]['token']
|
6
|
-
from_email= order.store.mail_from_address
|
7
|
-
from_name= Spree::BrontoConfiguration.account[store_code]['from_name']
|
8
|
-
reply_email= order.store.mail_from_address
|
9
|
-
|
10
|
-
email_options={:fromEmail =>from_email,:fromName => from_name, :replyEmail => reply_email}
|
11
|
-
communication = BrontoIntegration::Communication.new(token)
|
12
|
-
communication.trigger_delivery_by_id(message_name,email,'triggered',mail_type||'html',attributes||{},email_options)
|
13
|
-
rescue => exception
|
14
|
-
#raise exception # as now only campaign use this and their templates may not be approved. let it go.
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|