You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: commerce-add-ons/packages/cart/configuration.md
+25-25
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,11 @@ description: Learn how to configure the Umbraco Commerce Cart package.
4
4
5
5
# Configuration
6
6
7
-
The Cart package is configured using a JavaScript, CSS and data attributesbased API.
7
+
The Cart package is configured using a JavaScript, CSS, and data attributes-based API.
8
8
9
9
## Initialization
10
10
11
-
Before adding items to a cart, it is required the the Cart package is first initialized with some default settings. This is done using the `UCC.init` global function which should be executed after the `umbraco-commerce-cart.js` file is loaded.
11
+
Before adding items to a cart, it is required that the Cart package is initialized with some default settings. This is done using the `UCC.init` global function which should be executed after the `umbraco-commerce-cart.js` file is loaded.
@@ -23,23 +23,23 @@ Before adding items to a cart, it is required the the Cart package is first init
23
23
</script>
24
24
```
25
25
26
-
The core intialization settings are:
26
+
The core initialization settings are shown in the table below.
27
27
28
28
| Key | Description |
29
29
| -- | -- |
30
30
|`store`| The ID or alias of the store the cart should be associated with. |
31
31
|`checkoutUrl`| The URL of the checkout page the cart should redirect to on checkout. |
32
-
|`showPricesIncludingTax`| Define whether to show prices inclusive of exclusive of sales TAX. Defaults to `false`. |
32
+
|`showPricesIncludingTax`| Define whether to show prices inclusive or exclusive of sales tax. Defaults to `false`. |
33
33
34
34
Calling the `init` method will also automatically bind any UI elements configured using the following APIs.
35
35
36
36
## UI Elements
37
37
38
38
### Add to Cart Buttons
39
39
40
-
With Umbraco Commerce Cart, products that can be added to a cart are defined by adding attributes to HTML elements on your site. Most likely this will be a "buy" `<button>` element, however, any HTML element can become an add to cart component.
40
+
With Umbraco Commerce Cart, products that can be added to a cart are defined by adding attributes to HTML elements on your site. Most likely this will be a "buy" `<button>` element, however, any HTML element can become an add-to-cart component.
41
41
42
-
The first step when defining a add to cart component is to add the `ucc-add-to-cart` class to the element. This informs Umbraco Commerce Cart that it should react to that element's click event.
42
+
The first step when defining an add-to-cart component is to add the `ucc-add-to-cart` class to the element. This informs Umbraco Commerce Cart that it should react to that element's click event.
43
43
44
44
```html
45
45
<buttonclass="ucc-add-to-cart"
@@ -48,12 +48,12 @@ The first step when defining a add to cart component is to add the `ucc-add-to-c
48
48
</button>
49
49
```
50
50
51
-
Along with the `ucc-add-to-cart` class we also use a series of data attributes to provide information about the product being added to the cart. At minimum a `data-ucc-product-reference` is required, but the following table outlines all the available configuration options.
51
+
Along with the `ucc-add-to-cart` class, a series of data attributes provides information about the product being added to the cart. At a minimum, a `data-ucc-product-reference` is required, but the following table outlines all the available configuration options.
52
52
53
53
| Key | Description |
54
54
| -- | -- |
55
55
|`data-ucc-product-reference`| The unique reference for the product being added. This is usually the Key of the product Umbraco node. |
56
-
| `data-ucc-product-variant-reference` | The unique reference for a variant of the primary product being added. This is usually either a child variant nodes Key or the Key of a complex variant item from the Variants property editor.
56
+
| `data-ucc-product-variant-reference` | The unique reference for a variant of the primary product being added. This is usually either a child variant node Key or the Key of a complex variant item from the Variants property editor.
57
57
|`data-ucc-quantity`| The amount of the given product to be added. |
58
58
|`data-ucc-property1-key`| The key of a property to set on the added order line. |
59
59
|`data-ucc-property1-value`| The value of a property to set on the added order line. |
@@ -64,31 +64,31 @@ Along with the `ucc-add-to-cart` class we also use a series of data attributes t
64
64
|`data-ucc-bundle-item1-property1-key`| The key of a property to set on the added bundle item. |
65
65
|`data-ucc-bundle-item1-property1-value`| The value of a property to set on the added bundle item. |
66
66
67
-
Where an attribute ends with a number, this signifies that this attribute defines a collection and so multiple attributes can be defined with each distinct combination incrementing the number by `1`. It is important that these attributes start from `1` and must be sequential without gaps.
67
+
Some attributes end with a number. This signifies that the attribute defines a collection and so multiple attributes can be defined with each distinct combination incrementing the number by `1`. It is important that these attributes start from `1` and must be sequential without gaps.
68
68
69
-
With an add to cart button defined, clicking on the button should now automatically add the given product to the cart and open the cart for display.
69
+
With an add-to-cart button defined, clicking on the button will automatically add the given product to the cart and open the cart for display.
70
70
71
71

72
72
73
73
### Open Cart Button
74
74
75
-
Whilst the cart will open automatically when an item is added to the cart, it's also likely that you will want the ability for customers to open their carts manually. To do this you can add a `ucc-cart` class to a link or button element and Umbraco Commerce Cart will automatically bind a click event handler to trigger opening the cart.
75
+
While the cart will open automatically when an item is added, you can also enable the customers to open their carts manually. To do this, add a `ucc-cart` class to a link or button element. The Umbraco Commerce Cart will then automatically bind a click event handler to trigger opening the cart.
76
76
77
77
```html
78
78
<ahref="#"class="ucc-cart">Cart</a>
79
79
```
80
80
81
81
### Cart Count Label
82
82
83
-
Another common feature on commerce sites is the ability to display a total number of items in the current cart. To do this you can define a html element with a `ucc-cart-count` class applied and Umbraco Commerce Cart will automatically update it's text value whenever the cart changes.
83
+
Another common feature on commerce sites is the ability to display the total number of items in the current cart. To do this, define an HTML element with a `ucc-cart-count` class applied. Umbraco Commerce Cart will then automatically update its text value whenever the cart changes.
As well as the automatic API defined above, it is also possible to trigger Umbraco Commerce Cart commands manually via a number of JavaScript functions.
91
+
As well as the automatic API defined above, it is possible to trigger Umbraco Commerce Cart commands manually via a number of JavaScript functions.
92
92
93
93
```javascript
94
94
// Open the cart
@@ -106,7 +106,7 @@ UCC.setStore('brewed');
106
106
// Update the checkout URL
107
107
UCC.setCheckoutUrl('/new-checkout');
108
108
109
-
// Set whether to display prices inclusive of exclusive of sales TAX
109
+
// Set whether to display prices inclusive or exclusive of sales tax
110
110
UCC.showPricesIncludingTax(true);
111
111
112
112
// Show a property in the cart
@@ -129,7 +129,7 @@ UCC.setOnError(msg => {
129
129
130
130
## Localization
131
131
132
-
The cart UI supports being translated into any language. Out of the box it comes with a default English translation, but additional locales can be configured.
132
+
The cart UI supports being translated into any language. Out of the box, it comes with a default English translation, but additional locales can be configured.
133
133
134
134
Localization is controlled via the `lang` attribute in the `<html>` tag of your site.
135
135
@@ -146,7 +146,7 @@ Localization is controlled via the `lang` attribute in the `<html>` tag of your
146
146
147
147
In the above example, Umbraco Commerce Cart will look for a French locale. If a given locale can't be found, then it will default back to English.
148
148
149
-
Additional locales can be added either via the `UCC.init` method, or by calling the `UCC.addLocale` command.
149
+
Additional locales can be added either via the `UCC.init` method or by calling the `UCC.addLocale` command.
150
150
151
151
```javascript
152
152
// Init command example
@@ -182,7 +182,7 @@ UCC.addLocale('fr', {
182
182
})
183
183
```
184
184
185
-
The default English locale has the following values, and also defines the required keys for a locale.
185
+
The default English locale has the following values and defines the required keys for a locale.
186
186
187
187
```javascript
188
188
{
@@ -198,7 +198,7 @@ The default English locale has the following values, and also defines the requir
198
198
}
199
199
```
200
200
201
-
To override a locale you can re-add it reusing the same language key
201
+
To override a locale you can re-add it by reusing the same language key.
202
202
203
203
```javascript
204
204
// Init command example
@@ -222,9 +222,9 @@ UCC.addLocale('en', {
222
222
223
223
## Displaying Properties
224
224
225
-
If you capture any custom properties, you may wish to display them within the cart. Displaying properties is achieved in two steps.
225
+
If you capture any custom properties, you may want to display them within the cart. Displaying properties is achieved in two steps.
226
226
227
-
We first define the property keys we wish to display either via the `UCC.init` command, or the `UCC.showProperty` command.
227
+
First, you define the property keys you wish to display either via the `UCC.init` command, or the `UCC.showProperty` command.
228
228
229
229
```javascript
230
230
// Init command example
@@ -238,7 +238,7 @@ UCC.init({
238
238
UCC.showProperty('message');
239
239
```
240
240
241
-
Next we define a localization key to use as a label for each property.
241
+
Next, you define a localization key to use as a label for each property.
242
242
243
243
```javascript
244
244
// Init command example
@@ -262,13 +262,13 @@ UCC.addLocale('en', {
262
262
})
263
263
```
264
264
265
-
Now when the cart is displayed, the defined properties will be displayed using the localization value as their label.
265
+
Now, when the cart is displayed, the defined properties will be displayed using the localization value as their label.
266
266
267
267

268
268
269
269
## Theming
270
270
271
-
In order to allow customization of the cart UI, CSS variables are used to allow easy overiding of the default styles.
271
+
To allow customization of the cart UI, CSS variables are used to allow overriding of the default styles.
272
272
273
273
The following details the default values, and the available keys to override.
274
274
@@ -325,7 +325,7 @@ Styles can be overridden by including a stylesheet after the Umbraco Commerce Ca
325
325
326
326
## Error Handling
327
327
328
-
By default Umbraco Commerce Cart will just log any request errors to the console. If you would like to display errors to your users, or handle them differently you can do so by providing an error handler function.
328
+
By default, Umbraco Commerce Cart will log any request errors to the console. If you would like to display errors to your users or handle them differently you can provide an error handler function.
0 commit comments