spree_emails 5.3.0.rc2 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +210 -0
- metadata +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ad94798002ff9ee17fe903d6527b8d8951df1cc3e370daa70e13f6d4e54e8fbb
|
|
4
|
+
data.tar.gz: 141c28661d895e70ba76e1589a0dfd0107480b244f2fd96816b50316ace9cd13
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cdc75de88ca87e840265127578e5692773e5d1d0d267db04e23ef981c6a052f8930b3e78de95ace33ccb6333fd669a5f11d23a2d41fbdc41938b2552ec8e6813
|
|
7
|
+
data.tar.gz: 13784bb1809523a32ae1c8372aaef7d1bec77ebb620a54be57fbb966c8c5946b8a92d55dee51cda81af2e2e59038accaadfa0b94c49376568c2fa65a51c5c1dc
|
data/README.md
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Spree Emails
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/rb/spree_emails)
|
|
4
|
+
|
|
5
|
+
Spree Emails provides transactional email templates and mailers for Spree Commerce, handling order confirmations, shipment notifications, and other customer communications.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This gem includes:
|
|
10
|
+
|
|
11
|
+
- **Order Mailer** - Order confirmation and cancellation emails
|
|
12
|
+
- **Shipment Mailer** - Shipping and delivery notifications
|
|
13
|
+
- **Reimbursement Mailer** - Refund notifications
|
|
14
|
+
- **Event Subscribers** - Automatic email triggers on store events
|
|
15
|
+
- **Email Templates** - Customizable HTML and text templates
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
bundle add spree_emails
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Email Types
|
|
24
|
+
|
|
25
|
+
### Order Emails
|
|
26
|
+
|
|
27
|
+
- **Order Confirmation** - Sent when an order is completed
|
|
28
|
+
- **Order Cancellation** - Sent when an order is cancelled
|
|
29
|
+
|
|
30
|
+
### Shipment Emails
|
|
31
|
+
|
|
32
|
+
- **Shipment Notification** - Sent when a shipment is shipped
|
|
33
|
+
- **Delivery Confirmation** - Sent when tracking shows delivered
|
|
34
|
+
|
|
35
|
+
### Reimbursement Emails
|
|
36
|
+
|
|
37
|
+
- **Refund Notification** - Sent when a reimbursement is processed
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
Transactional emails are controlled per-store via the `send_consumer_transactional_emails` preference. This can be configured in the admin dashboard under Store Settings, or programmatically:
|
|
42
|
+
|
|
43
|
+
```ruby
|
|
44
|
+
# Enable/disable transactional emails for a store
|
|
45
|
+
store = Spree::Store.current
|
|
46
|
+
store.update(send_consumer_transactional_emails: true)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The sender address is configured via the `mail_from_address` attribute on each store:
|
|
50
|
+
|
|
51
|
+
```ruby
|
|
52
|
+
store.update(mail_from_address: 'orders@example.com')
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Action Mailer Configuration
|
|
56
|
+
|
|
57
|
+
```ruby
|
|
58
|
+
# config/environments/production.rb
|
|
59
|
+
config.action_mailer.delivery_method = :smtp
|
|
60
|
+
config.action_mailer.smtp_settings = {
|
|
61
|
+
address: 'smtp.example.com',
|
|
62
|
+
port: 587,
|
|
63
|
+
user_name: ENV['SMTP_USERNAME'],
|
|
64
|
+
password: ENV['SMTP_PASSWORD'],
|
|
65
|
+
authentication: 'plain',
|
|
66
|
+
enable_starttls_auto: true
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Customization
|
|
71
|
+
|
|
72
|
+
### Overriding Templates
|
|
73
|
+
|
|
74
|
+
Copy email templates to your application:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Copy all email templates
|
|
78
|
+
cp -r $(bundle show spree_emails)/app/views/spree/mailer app/views/spree/
|
|
79
|
+
|
|
80
|
+
# Or copy specific templates
|
|
81
|
+
cp $(bundle show spree_emails)/app/views/spree/mailer/order_mailer/confirm_email.html.erb \
|
|
82
|
+
app/views/spree/mailer/order_mailer/
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Template Structure
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
app/views/spree/mailer/
|
|
89
|
+
├── order_mailer/
|
|
90
|
+
│ ├── confirm_email.html.erb
|
|
91
|
+
│ ├── confirm_email.text.erb
|
|
92
|
+
│ ├── cancel_email.html.erb
|
|
93
|
+
│ └── cancel_email.text.erb
|
|
94
|
+
├── shipment_mailer/
|
|
95
|
+
│ ├── shipped_email.html.erb
|
|
96
|
+
│ └── shipped_email.text.erb
|
|
97
|
+
└── reimbursement_mailer/
|
|
98
|
+
├── reimbursement_email.html.erb
|
|
99
|
+
└── reimbursement_email.text.erb
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Custom Mailer
|
|
103
|
+
|
|
104
|
+
Create custom mailers by extending Spree's base mailer:
|
|
105
|
+
|
|
106
|
+
```ruby
|
|
107
|
+
# app/mailers/spree/order_mailer_decorator.rb
|
|
108
|
+
module Spree
|
|
109
|
+
module OrderMailerDecorator
|
|
110
|
+
def confirm_email(order, resend = false)
|
|
111
|
+
@custom_data = fetch_custom_data(order)
|
|
112
|
+
super
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
private
|
|
116
|
+
|
|
117
|
+
def fetch_custom_data(order)
|
|
118
|
+
# Custom logic
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
Spree::OrderMailer.prepend(Spree::OrderMailerDecorator)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Adding New Email Types
|
|
127
|
+
|
|
128
|
+
```ruby
|
|
129
|
+
# app/mailers/spree/custom_mailer.rb
|
|
130
|
+
module Spree
|
|
131
|
+
class CustomMailer < BaseMailer
|
|
132
|
+
def welcome_email(user)
|
|
133
|
+
@user = user
|
|
134
|
+
mail(to: @user.email, subject: 'Welcome to our store!')
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Event Integration
|
|
141
|
+
|
|
142
|
+
Emails are triggered via Spree's event system. Create custom subscribers:
|
|
143
|
+
|
|
144
|
+
```ruby
|
|
145
|
+
# app/subscribers/spree/custom_email_subscriber.rb
|
|
146
|
+
module Spree
|
|
147
|
+
module CustomEmailSubscriber
|
|
148
|
+
include Spree::Event::Subscriber
|
|
149
|
+
|
|
150
|
+
event_action :user_registered
|
|
151
|
+
|
|
152
|
+
def user_registered(event)
|
|
153
|
+
user = event.payload[:user]
|
|
154
|
+
Spree::CustomMailer.welcome_email(user).deliver_later
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Disabling Emails
|
|
161
|
+
|
|
162
|
+
Disable transactional emails for a specific store:
|
|
163
|
+
|
|
164
|
+
```ruby
|
|
165
|
+
store = Spree::Store.current
|
|
166
|
+
store.update(send_consumer_transactional_emails: false)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
This setting can also be managed in the admin dashboard under Store Settings.
|
|
170
|
+
|
|
171
|
+
To disable all Spree transactional emails globally, remove this gem from your application:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
bundle remove spree_emails
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Using Third-Party Email Services
|
|
178
|
+
|
|
179
|
+
If you prefer to use a third-party email service like Klaviyo for transactional emails, you can use the [spree_klaviyo](https://github.com/spree/spree_klaviyo) extension. This allows you to leverage Klaviyo's email marketing platform for order confirmations, shipment notifications, and other transactional emails.
|
|
180
|
+
|
|
181
|
+
## Testing
|
|
182
|
+
|
|
183
|
+
Preview emails in development:
|
|
184
|
+
|
|
185
|
+
```ruby
|
|
186
|
+
# test/mailers/previews/spree/order_mailer_preview.rb
|
|
187
|
+
module Spree
|
|
188
|
+
class OrderMailerPreview < ActionMailer::Preview
|
|
189
|
+
def confirm_email
|
|
190
|
+
order = Spree::Order.complete.last
|
|
191
|
+
Spree::OrderMailer.confirm_email(order)
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Visit `http://localhost:3000/rails/mailers/spree/order_mailer/confirm_email`
|
|
198
|
+
|
|
199
|
+
Run the test suite:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
cd emails
|
|
203
|
+
bundle exec rake test_app # First time only
|
|
204
|
+
bundle exec rspec
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Documentation
|
|
208
|
+
|
|
209
|
+
- [Email Customization Guide](https://docs.spreecommerce.org/developer/customization/emails)
|
|
210
|
+
- [Events System](https://docs.spreecommerce.org/developer/core-concepts/events)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_emails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.3.0
|
|
4
|
+
version: 5.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sean Schofield
|
|
@@ -17,14 +17,14 @@ dependencies:
|
|
|
17
17
|
requirements:
|
|
18
18
|
- - ">="
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: 5.3.0
|
|
20
|
+
version: 5.3.0
|
|
21
21
|
type: :runtime
|
|
22
22
|
prerelease: false
|
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
24
|
requirements:
|
|
25
25
|
- - ">="
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
|
-
version: 5.3.0
|
|
27
|
+
version: 5.3.0
|
|
28
28
|
- !ruby/object:Gem::Dependency
|
|
29
29
|
name: email_spec
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -47,6 +47,7 @@ extensions: []
|
|
|
47
47
|
extra_rdoc_files: []
|
|
48
48
|
files:
|
|
49
49
|
- LICENSE.md
|
|
50
|
+
- README.md
|
|
50
51
|
- Rakefile
|
|
51
52
|
- app/assets/config/spree_emails_manifest.js
|
|
52
53
|
- app/assets/images/logo/spree_50.png
|
|
@@ -99,9 +100,9 @@ licenses:
|
|
|
99
100
|
- BSD-3-Clause
|
|
100
101
|
metadata:
|
|
101
102
|
bug_tracker_uri: https://github.com/spree/spree/issues
|
|
102
|
-
changelog_uri: https://github.com/spree/spree/releases/tag/v5.3.0
|
|
103
|
+
changelog_uri: https://github.com/spree/spree/releases/tag/v5.3.0
|
|
103
104
|
documentation_uri: https://docs.spreecommerce.org/
|
|
104
|
-
source_code_uri: https://github.com/spree/spree/tree/v5.3.0
|
|
105
|
+
source_code_uri: https://github.com/spree/spree/tree/v5.3.0
|
|
105
106
|
rdoc_options: []
|
|
106
107
|
require_paths:
|
|
107
108
|
- lib
|