Skip to content

Commit 4432e39

Browse files
Sofie Toft Kristensengitbook-bot
authored andcommitted
GITBOOK-14: Customizing Templates
1 parent de11f82 commit 4432e39

File tree

4 files changed

+175
-198
lines changed

4 files changed

+175
-198
lines changed
Binary file not shown.

13/umbraco-commerce/SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
* [Add item to Cart](how-to-guides/add-item.md)
3939
* [Update Cart](how-to-guides/update-cart.md)
4040
* [Delete item in Cart](how-to-guides/delete-item.md)
41+
* [Customizing Templates](how-to-guides/customizing-templates.md)
4142

4243
## Key Concepts
4344

@@ -47,7 +48,7 @@
4748
* [Calculators](key-concepts/calculators.md)
4849
* [Dependency Injection](key-concepts/dependency-injection.md)
4950
* [Discount Rules / Rewards](key-concepts/discount-rules-and-rewards.md)
50-
* [Events](key-concepts/events)
51+
* [Events](key-concepts/events/README.md)
5152
* [List of validation events](key-concepts/events/list-of-validation-events.md)
5253
* [List of notification events](key-concepts/events/list-of-notification-events.md)
5354
* [Fluent API](key-concepts/fluent-api.md)
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
description: Learn how to create custom templates for emails, prints, and exports.
3+
---
4+
5+
# Customizing Templates
6+
7+
Umbraco Commerce provides support for customizing templates for emails, prints, and exports. This allows you to tailor the outputs of your e-commerce solution to meet specific branding or functional requirements.
8+
9+
## Accessing the Default Built-in Templates
10+
11+
The default templates for email, print, and export are embedded in Razor Class Libraries (RCLs) in Umbraco Commerce. To customize these templates, you can extract them and use them as a starting point.
12+
13+
Download the custom templates and place them in `/Views/Partials/Commerce/Email/`.
14+
15+
{% file src="../.gitbook/assets/Umbraco.Commerce.Templates.v13.zip" %}
16+
Umbraco Commerce Custom Templates
17+
{% endfile %}
18+
19+
## Creating Custom Templates
20+
21+
### Email Templates
22+
23+
To Create a Custom Email Template:
24+
25+
1. Create a Razor view file (`.cshtml`) in `/Views/Partials/Commerce/Email/.`
26+
2. Implement the `IEmailTemplate` interface to make the template available in Umbraco Commerce:
27+
28+
```csharp
29+
using Umbraco.Commerce.Core.Interfaces;
30+
31+
public class CustomOrderEmailTemplate : IEmailTemplate
32+
{
33+
public virtual string FileName => "CustomOrderEmail.cshtml";
34+
}
35+
36+
```
37+
38+
3. Register the Template in a Composer:
39+
40+
```csharp
41+
using Umbraco.Cms.Core.Composing;
42+
using Umbraco.Cms.Core.DependencyInjection;
43+
44+
public class CustomTemplateComposer : IComposer
45+
{
46+
public void Compose(IUmbracoBuilder builder)
47+
{
48+
builder.EmailTemplates().Add<CustomOrderEmailTemplate>();
49+
}
50+
}
51+
52+
```
53+
54+
### Print and Export Templates
55+
56+
To create Print/Export Templates:
57+
58+
1. Create a Razor view file (`.cshtml`) under the relevant paths:
59+
60+
```
61+
/Views/Partials/Commerce/Prints/
62+
/Views/Partials/Commerce/Exports/
63+
```
64+
65+
2. Implement the `IPrintTemplate` or `IExportTemplate` interface to make the template available in Umbraco Commerce.
66+
3. Register the template in a Composer similar to the email template process.
67+
68+
## Shipping Custom Templates in a Razor Class Library
69+
70+
To distribute custom templates as part of a Razor Class Library (RCL):
71+
72+
1. Create a new Razor Class Library project.
73+
2. Add the template files under appropriate paths, for example, `Views/Partials/Commerce/Emails/`.
74+
3. Implement interfaces like `IEmailTemplate,` `IPrintTemplate,`or `IExportTemplate` .
75+
4. Use a composer to register your custom templates.
Lines changed: 98 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -1,197 +1,98 @@
1-
---
2-
description: Information on Umbraco Commerce Stores
3-
---
4-
5-
# Stores
6-
7-
Stores represent a single shop / commercial entity and contain all the settings a configuration specific to that particular store. They are the root entity from which all other Umbraco Commerce entities are connected. They are also able to be linked to content nodes to connect a store to a site.
8-
9-
## Store Settings
10-
11-
General settings for a store can be accessed via the UI by clicking on a store node in the `Settings > Commerce` section.
12-
13-
### General
14-
15-
<table>
16-
<thead>
17-
<tr>
18-
<th width="200">Name</th>
19-
<th>Description</th>
20-
</tr>
21-
</thead>
22-
<tbody>
23-
<tr>
24-
<td>Base Currency</td>
25-
<td>Defines the base currency a store operates in and for which all order values will be converted for the basis of reporting and analytics.</td>
26-
27-
</tr>
28-
<tr>
29-
<td>Default Location</td>
30-
<td>Defines the main location of the store and is used by shipping calculators to work out shipping rates.</td>
31-
</tr>
32-
<tr>
33-
<td>Default Country</td>
34-
<td>Defines the default country of the store and is used to set the default payment/shipping country of newly created orders.</td>
35-
36-
</tr>
37-
<tr>
38-
<td>Default Order Status</td>
39-
<td>Defines the order status to assign newly created orders to.</td>
40-
</tr>
41-
<tr>
42-
<td>Error Order Status</td>
43-
<td>Defines the order status to assign orders to when an error occurs during order processing.</td>
44-
45-
</tr>
46-
<tr>
47-
<td>Measurement System</td>
48-
<td>Defines whether to use a Metric or Imperial measurement system when capturing product measurement.</td>
49-
50-
</tr>
51-
<tr>
52-
<td>Prices Include Tax</td>
53-
<td>Defines whether all prices entered into the system are inclusive or exclusive of tax.</td>
54-
</tr>
55-
<tr>
56-
<td>Use Cookies</td>
57-
<td>Defines whether cookies should be used for tracking a customers current order, allowing them to last between browser sessions.</td>
58-
</tr>
59-
<tr>
60-
<td>Cookie Timeout</td>
61-
<td>If using cookies, defines the length of time in minutes the cookie should be persisted for.</td>
62-
</tr>
63-
</tbody>
64-
</table>
65-
66-
### Notification Settings
67-
68-
<table>
69-
<thead>
70-
<tr>
71-
<th width="200">Name</th>
72-
<th>Description</th>
73-
</tr>
74-
</thead>
75-
<tbody>
76-
<tr>
77-
<td>Confirmation Email</td>
78-
<td>Defines the email to send to customers when an order is successfully completed.</td>
79-
</tr>
80-
<tr>
81-
<td>Error Email</td>
82-
<td>Defines the email to send to customers when an error occurs completing their order.</td>
83-
</tr>
84-
</tbody>
85-
</table>
86-
87-
### Order Settings
88-
89-
<table>
90-
<thead>
91-
<tr>
92-
<th width="200">Name</th>
93-
<th>Description</th>
94-
</tr>
95-
</thead>
96-
<tbody>
97-
<tr>
98-
<td>Cart Number Template</td>
99-
<td>Defines a string formatting template to use when generating a Cart Number, eg: 'CART-{0}'.</td>
100-
</tr>
101-
<tr>
102-
<td>Order Number Template</td>
103-
<td>Defines a string formatting template to use when generating an Order Number, eg: 'ORDER-{0}'.</td>
104-
</tr>
105-
<tr>
106-
<td>Order Rounding Method</td>
107-
<td>Defines At what level in the order calculation process prices should be rounded. Can be either `Unit` where prices are rounded at the item level, `Line` where prices are rounded at the order line level after quantity multiplication or `Total` where prices are rounded at the order total level.</td>
108-
</tr>
109-
</tbody>
110-
</table>
111-
112-
### Product Settings
113-
114-
<table>
115-
<thead>
116-
<tr>
117-
<th width="200">Name</th>
118-
<th>Description</th>
119-
</tr>
120-
</thead>
121-
<tbody>
122-
<tr>
123-
<td>Product Property Aliases</td>
124-
<td>Defines a comma-separated list of property aliases to be copied to the order line when added to the cart. See the [Properties concept documentation](../../key-concepts/properties.md#automatic-properties) for more details.</td>
125-
</tr>
126-
<tr>
127-
<td>Product Uniqueness Property Aliases</td>
128-
<td>Defines a comma-separated list of property aliases to be used to define product uniqueness. See the [Properties concept documentation](../../key-concepts/properties.md#product-uniqueness-properties) for more details.</td>
129-
130-
</tr>
131-
</tbody>
132-
</table>
133-
134-
### Gift Card Settings
135-
136-
<table>
137-
<thead>
138-
<tr>
139-
<th width="200">Name</th>
140-
<th>Description</th>
141-
</tr>
142-
</thead>
143-
<tbody>
144-
<tr>
145-
<td>Code Length</td>
146-
<td>Defines the length of a gift card code when auto-generated.</td>
147-
</tr>
148-
<tr>
149-
<td>Code Template</td>
150-
<td>Defines a string formatting template to use when auto-generating a gift card code, eg: 'GIFTCARD-{0}'.</td>
151-
</tr>
152-
<tr>
153-
<td>Valid For</td>
154-
<td>Defines the number of days gift cards should be valid for by default.</td>
155-
</tr>
156-
<tr>
157-
<td>Gift Card Property Aliases</td>
158-
<td>Defines a comma-separated list of property aliases to be copied to the gift card from the order line.</td>
159-
</tr>
160-
<tr>
161-
<td>Activation Method</td>
162-
<td>Defines the method by which gift cards become active. Can be `Manual` where the store owner must manually active the gift card, `Automatic` where the gift card automatically becomes active after purchase or `Order Status` where the gift card becomes active when the purchase order moves into a specific order status.</td>
163-
</tr>
164-
<tr>
165-
<td>Activation Order Status</td>
166-
<td>When the activation method is `Order Status`, it defines the order status that activates the gift card.</td>
167-
</tr>
168-
<tr>
169-
<td>Default Gift Card Email</td>
170-
<td>Defines the email to be sent to customers if an order contains a gift card item.</td>
171-
</tr>
172-
</tbody>
173-
</table>
174-
175-
## Store Configuration
176-
177-
Further store configuration can be achieved by setting up different categories of configuration that can be accessed as child nodes to the store node.
178-
179-
The available configuration options are:
180-
181-
* **Locations** - Defines different locations for a store. See [Locations reference documentation](../locations/README.md) for more details.
182-
* **Order Statuses** - Defines the order statuses to be used by a store.
183-
* **Shipping Methods** - Defines the different shipping options available in the store. See [Shipping reference documentation](../shipping/README.md) for more details.
184-
* **Payment Methods** - Defines the different payment options available in the store.
185-
* **Countries** - Defines the different shipping countries supported by the store.
186-
* **Currencies** - Defines the different currencies accepted by the store.
187-
* **Taxes** - Defines the different rates supported by the store.
188-
* **Templating** - Defines the different email, print, and export templates available to the store.
189-
190-
## Store Permissions
191-
192-
When editing a store, the permissions app allows you to control who can access the store management interface. The options are:
193-
194-
* **User Groups** - A set of toggles to allow/deny access to members of a particular user group.
195-
* **Users** - A set of toggles to allow/deny access to explicit individuals.
196-
197-
In both cases, a positive access control will always override a deny control setting.
1+
---
2+
description: Information on Umbraco Commerce Stores
3+
---
4+
5+
# Stores
6+
7+
Stores represent a single shop / commercial entity and contain all the settings a configuration specific to that particular store. They are the root entity from which all other Umbraco Commerce entities are connected. They are also able to be linked to content nodes to connect a store to a site.
8+
9+
## Store Settings
10+
11+
General settings for a store can be accessed via the UI by clicking on a store node in the `Settings > Commerce` section.
12+
13+
### General
14+
15+
```
16+
</tr>
17+
<tr>
18+
<td>Default Location</td>
19+
<td>Defines the main location of the store and is used by shipping calculators to work out shipping rates.</td>
20+
</tr>
21+
<tr>
22+
<td>Default Country</td>
23+
<td>Defines the default country of the store and is used to set the default payment/shipping country of newly created orders.</td>
24+
25+
</tr>
26+
<tr>
27+
<td>Default Order Status</td>
28+
<td>Defines the order status to assign newly created orders to.</td>
29+
</tr>
30+
<tr>
31+
<td>Error Order Status</td>
32+
<td>Defines the order status to assign orders to when an error occurs during order processing.</td>
33+
34+
</tr>
35+
<tr>
36+
<td>Measurement System</td>
37+
<td>Defines whether to use a Metric or Imperial measurement system when capturing product measurement.</td>
38+
39+
</tr>
40+
<tr>
41+
<td>Prices Include Tax</td>
42+
<td>Defines whether all prices entered into the system are inclusive or exclusive of tax.</td>
43+
</tr>
44+
<tr>
45+
<td>Use Cookies</td>
46+
<td>Defines whether cookies should be used for tracking a customers current order, allowing them to last between browser sessions.</td>
47+
</tr>
48+
<tr>
49+
<td>Cookie Timeout</td>
50+
<td>If using cookies, defines the length of time in minutes the cookie should be persisted for.</td>
51+
</tr>
52+
```
53+
54+
<table><thead><tr><th width="200">Name</th><th>Description</th></tr></thead><tbody><tr><td>Base Currency</td><td>Defines the base currency a store operates in and for which all order values will be converted for the basis of reporting and analytics.</td></tr></tbody></table>
55+
56+
### Notification Settings
57+
58+
<table><thead><tr><th width="200">Name</th><th>Description</th></tr></thead><tbody><tr><td>Confirmation Email</td><td>Defines the email to send to customers when an order is successfully completed.</td></tr><tr><td>Error Email</td><td>Defines the email to send to customers when an error occurs completing their order.</td></tr></tbody></table>
59+
60+
### Order Settings
61+
62+
<table><thead><tr><th width="200">Name</th><th>Description</th></tr></thead><tbody><tr><td>Cart Number Template</td><td>Defines a string formatting template to use when generating a Cart Number, eg: 'CART-{0}'.</td></tr><tr><td>Order Number Template</td><td>Defines a string formatting template to use when generating an Order Number, eg: 'ORDER-{0}'.</td></tr><tr><td>Order Rounding Method</td><td>Defines At what level in the order calculation process prices should be rounded. Can be either `Unit` where prices are rounded at the item level, `Line` where prices are rounded at the order line level after quantity multiplication or `Total` where prices are rounded at the order total level.</td></tr></tbody></table>
63+
64+
### Product Settings
65+
66+
```
67+
</tr>
68+
```
69+
70+
<table><thead><tr><th width="200">Name</th><th>Description</th></tr></thead><tbody><tr><td>Product Property Aliases</td><td>Defines a comma-separated list of property aliases to be copied to the order line when added to the cart. See the [Properties concept documentation](../../key-concepts/properties.md#automatic-properties) for more details.</td></tr><tr><td>Product Uniqueness Property Aliases</td><td>Defines a comma-separated list of property aliases to be used to define product uniqueness. See the [Properties concept documentation](../../key-concepts/properties.md#product-uniqueness-properties) for more details.</td></tr></tbody></table>
71+
72+
### Gift Card Settings
73+
74+
<table><thead><tr><th width="200">Name</th><th>Description</th></tr></thead><tbody><tr><td>Code Length</td><td>Defines the length of a gift card code when auto-generated.</td></tr><tr><td>Code Template</td><td>Defines a string formatting template to use when auto-generating a gift card code, eg: 'GIFTCARD-{0}'.</td></tr><tr><td>Valid For</td><td>Defines the number of days gift cards should be valid for by default.</td></tr><tr><td>Gift Card Property Aliases</td><td>Defines a comma-separated list of property aliases to be copied to the gift card from the order line.</td></tr><tr><td>Activation Method</td><td>Defines the method by which gift cards become active. Can be `Manual` where the store owner must manually active the gift card, `Automatic` where the gift card automatically becomes active after purchase or `Order Status` where the gift card becomes active when the purchase order moves into a specific order status.</td></tr><tr><td>Activation Order Status</td><td>When the activation method is `Order Status`, it defines the order status that activates the gift card.</td></tr><tr><td>Default Gift Card Email</td><td>Defines the email to be sent to customers if an order contains a gift card item.</td></tr></tbody></table>
75+
76+
## Store Configuration
77+
78+
Further store configuration can be achieved by setting up different categories of configuration that can be accessed as child nodes to the store node.
79+
80+
The available configuration options are:
81+
82+
* **Locations** - Defines different locations for a store. See [Locations reference documentation](broken-reference) for more details.
83+
* **Order Statuses** - Defines the order statuses to be used by a store.
84+
* **Shipping Methods** - Defines the different shipping options available in the store. See [Shipping reference documentation](../shipping/) for more details.
85+
* **Payment Methods** - Defines the different payment options available in the store.
86+
* **Countries** - Defines the different shipping countries supported by the store.
87+
* **Currencies** - Defines the different currencies accepted by the store.
88+
* **Taxes** - Defines the different rates supported by the store.
89+
* **Templating** - Defines the different email, print, and export templates available to the store.
90+
91+
## Store Permissions
92+
93+
When editing a store, the permissions app allows you to control who can access the store management interface. The options are:
94+
95+
* **User Groups** - A set of toggles to allow/deny access to members of a particular user group.
96+
* **Users** - A set of toggles to allow/deny access to explicit individuals.
97+
98+
In both cases, a positive access control will always override a deny control setting.

0 commit comments

Comments
 (0)