Skip to content

Commit 239f83a

Browse files
committed
Commerce Template hooks overhaul, source branch naming
1 parent 942fb15 commit 239f83a

File tree

13 files changed

+166
-53
lines changed

13 files changed

+166
-53
lines changed

docs/commerce/3.x/customers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ If a customer chooses to register an account on order completion, a Craft user a
8080

8181
If any of the above fail, the user account will not be created; errors will be logged but not displayed or returned.
8282

83-
The Commerce [example templates](https://github.com/craftcms/commerce/blob/main/example-templates/dist/shop/checkout/payment.twig) display a “Register me for a user account” checkbox at the payment stage—but only if a user account doesn’t already exist for the email address on the cart:
83+
The Commerce [example templates](https://github.com/craftcms/commerce/blob/3.x/example-templates/dist/shop/checkout/payment.twig) display a “Register me for a user account” checkbox at the payment stage—but only if a user account doesn’t already exist for the email address on the cart:
8484

8585
```twig
8686
{# Get a user account using the same email address as the cart #}

docs/commerce/3.x/orders-carts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ axios.get('', {
8282

8383
Either of the examples above will generate a new cart in the session if none exists. While it’s unlikely you would make this assignment more than once per page request, getting the cart more than once does not affect performance.
8484

85-
To see what cart information you can use in your templates, take a look at the [Order](commerce3:craft\commerce\elements\Order) class reference. You can also see sample Twig in the example templates’ [`shop/cart/index.twig`](https://github.com/craftcms/commerce/blob/main/example-templates/dist/shop/cart/index.twig).
85+
To see what cart information you can use in your templates, take a look at the [Order](commerce3:craft\commerce\elements\Order) class reference. You can also see sample Twig in the example templates’ [`shop/cart/index.twig`](https://github.com/craftcms/commerce/blob/3.x/example-templates/dist/shop/cart/index.twig).
8686

8787
<toggle-tip title="Example Order">
8888

@@ -270,7 +270,7 @@ You can remove a line item by including a `remove` parameter in the request. Thi
270270
```
271271

272272
::: tip
273-
The [example templates](example-templates.md) include a [detailed cart template](https://github.com/craftcms/commerce/blob/main/example-templates/dist/shop/cart/index.twig) for adding and updating items in a full checkout flow.
273+
The [example templates](example-templates.md) include a [detailed cart template](https://github.com/craftcms/commerce/blob/3.x/example-templates/dist/shop/cart/index.twig) for adding and updating items in a full checkout flow.
274274
:::
275275

276276
#### Options Uniqueness
@@ -577,7 +577,7 @@ This will set temporarily the order’s calculation mode to *Recalculate All* an
577577

578578
### Order Notices
579579

580-
Notices are added to an order whenever it changes, whether it’s the customer saving the cart or a store manager recalculating from the control panel. Each notice is an [OrderNotice](https://github.com/craftcms/commerce/blob/main/src/models/OrderNotice.php) model describing what changed and could include the following:
580+
Notices are added to an order whenever it changes, whether it’s the customer saving the cart or a store manager recalculating from the control panel. Each notice is an [OrderNotice](https://github.com/craftcms/commerce/blob/3.x/src/models/OrderNotice.php) model describing what changed and could include the following:
581581

582582
- A previously-valid coupon or shipping method was removed from the order.
583583
- A line item’s purchasable was no longer available so that line item was removed from the cart.

docs/commerce/3.x/pdfs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ You’ll need to enter a few details:
1515
- **Name** is whatever you’d like to call the PDF in the control panel.
1616
- **Handle** is a reference to be used in templates.
1717
- **Description** is an optional note for explaining the template’s layout or purpose.
18-
- **PDF Template Path** should point to the Twig template that should be used for rendering the PDF file. (Add the [receipt example template](https://github.com/craftcms/commerce/blob/main/example-templates/dist/shop/_private/receipt/index.twig) here if you’d like to see one in action.)
18+
- **PDF Template Path** should point to the Twig template that should be used for rendering the PDF file. (Add the [receipt example template](https://github.com/craftcms/commerce/blob/3.x/example-templates/dist/shop/_private/receipt/index.twig) here if you’d like to see one in action.)
1919
- **Order PDF Filename Format** determines what the generated filename should look like. It can include tags for outputting order properties such as `{number}` or `{myOrderCustomField}`. (A `.pdf` extension will automatically be appended so you don’t need to add it here.)
2020
- **Enabled?** can be used to quickly toggle the PDF and control whether it’s available and sent in emails configured to use it.
2121
- **Default Order PDF** will appear only when you’re editing an additional or non-default PDF. Select this checkbox to make the current template the new default when you save it.
@@ -38,7 +38,7 @@ Create a new [order status email](emails.md) or select an existing one. You’ll
3838

3939
## Creating PDF Templates
4040

41-
It might be easiest to start by modifying the [example receipt template](https://github.com/craftcms/commerce/blob/main/example-templates/dist/shop/_private/receipt/index.twig), previewing it in a browser for convenience until things are mostly as you’d like them.
41+
It might be easiest to start by modifying the [example receipt template](https://github.com/craftcms/commerce/blob/3.x/example-templates/dist/shop/_private/receipt/index.twig), previewing it in a browser for convenience until things are mostly as you’d like them.
4242

4343
Avoid extending your regular site layouts for PDF templates, since your site most likely includes references to scripts and styles that may cause issues with PDF conversion.
4444

docs/commerce/3.x/tax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ You would like to charge 10% tax on all electronic items and 5% tax on everythin
309309

310310
## Templating
311311

312-
It’s common to display tax information to a customer in the context of their cart, since applicable taxes may depend on order items and the shipping address. Check out the [cart](https://github.com/craftcms/commerce/blob/main/example-templates/dist/shop/cart/index.twig) in the Commerce [example templates](example-templates.md), which includes taxable totals.
312+
It’s common to display tax information to a customer in the context of their cart, since applicable taxes may depend on order items and the shipping address. Check out the [cart](https://github.com/craftcms/commerce/blob/3.x/example-templates/dist/shop/cart/index.twig) in the Commerce [example templates](example-templates.md), which includes taxable totals.
313313

314314
## Further Reading
315315

docs/commerce/3.x/upgrading.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ If you’re upgrading from Commerce 1, see the [Changes in Commerce 2](https://c
88

99
Before you begin, make sure that:
1010

11-
1. You’ve reviewed the [changes in Commerce 3](https://github.com/craftcms/commerce/blob/main/CHANGELOG.md#300---2020-01-28)
11+
1. You’ve reviewed the [changes in Commerce 3](https://github.com/craftcms/commerce/blob/3.x/CHANGELOG.md#300---2020-01-28)
1212
2. Your site’s running at least **Craft 3.4** and **the latest version of Commerce 2** (2.2.27)
1313
3. Your **database is backed up** in case everything goes horribly wrong
1414

docs/commerce/4.x/extend/template-hooks.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ Commerce adds its own [template hooks](/4.x/extend/template-hooks.md) in additio
66

77
| Hook | Description & Template
88
| ---------------------------------------- | ----------------------
9-
| `cp.commerce.discount.edit` | After discount detail view’s “Enabled” field.<br><small>[promotions/discounts/_edit.twig](https://github.com/craftcms/commerce/blob/main/src/templates/promotions/discounts/_edit.twig)</small>
10-
| `cp.commerce.discounts.edit.content` | After discount detail view’s main content.<br><small>[promotions/discounts/_edit.twig](https://github.com/craftcms/commerce/blob/main/src/templates/promotions/discounts/_edit.twig)</small>
11-
| `cp.commerce.discounts.edit.details` | After discount detail view’s existing right sidebar details column.<br><small>[promotions/discounts/_edit.twig](https://github.com/craftcms/commerce/blob/main/src/templates/promotions/discounts/_edit.twig)</small>
12-
| `cp.commerce.discounts.edit` | Before discount detail view’s template blocks.<br><small>[promotions/discounts/_edit.twig](https://github.com/craftcms/commerce/blob/main/src/templates/promotions/discounts/_edit.twig)</small>
13-
| `cp.commerce.discounts.index` | After discounts index view’s main content.<br><small>[promotions/discounts/index.twig](https://github.com/craftcms/commerce/blob/main/src/templates/promotions/discounts/index.twig)</small>
14-
| `cp.commerce.order.edit` | Before order edit view’s template blocks.<br><small>[orders/_edit.twig](https://github.com/craftcms/commerce/blob/main/src/templates/orders/_edit.twig)</small>
15-
| `cp.commerce.order.edit.details` | After existing order edit view’s right sidebar details.<br><small>[orders/_edit.twig](https://github.com/craftcms/commerce/blob/main/src/templates/orders/_edit.twig)</small>
16-
| `cp.commerce.order.edit.main-pane` | After existing content within order edit view’s “Order Details” tab.<br><small>[orders/_edit.twig](https://github.com/craftcms/commerce/blob/main/src/templates/orders/_edit.twig)</small>
17-
| `cp.commerce.product.edit.content` | After product detail view’s custom fields.<br><small>[products/_edit.twig](https://github.com/craftcms/commerce/blob/main/src/templates/products/_edit.twig)</small>
18-
| `cp.commerce.product.edit.details` | After existing product detail view’s right sidebar details.<br><small>[products/_edit.twig](https://github.com/craftcms/commerce/blob/main/src/templates/products/_edit.twig)</small>
19-
| `cp.commerce.sales.edit.content` | After sale detail view’s main content.<br><small>[promotions/sales/_edit.twig](https://github.com/craftcms/commerce/blob/main/src/templates/promotions/sales/_edit.twig)</small>
20-
| `cp.commerce.sales.edit.details` | After sale detail view’s existing right sidebar details column.<br><small>[promotions/sales/_edit.twig](https://github.com/craftcms/commerce/blob/main/src/templates/promotions/sales/_edit.twig)</small>
21-
| `cp.commerce.sales.edit` | Before sale detail view’s template blocks.<br><small>[promotions/sales/_edit.twig](https://github.com/craftcms/commerce/blob/main/src/templates/promotions/sales/_edit.twig)</small>
22-
| `cp.commerce.sales.index` | After sales index view’s main content.<br><small>[promotions/sales/index.twig](https://github.com/craftcms/commerce/blob/main/src/templates/promotions/sales/index.twig)</small>
23-
| `cp.commerce.subscriptions.edit.content` | After the last `.pane` in subscription detail view’s content block.<br><small>[subscriptions/_edit.twig](https://github.com/craftcms/commerce/blob/main/src/templates/subscriptions/_edit.twig)</small>
24-
| `cp.commerce.subscriptions.edit.meta` | After the discount detail view’s existing right sidebar details.<br><small>[subscriptions/_edit.twig](https://github.com/craftcms/commerce/blob/main/src/templates/subscriptions/_edit.twig)</small>
9+
| `cp.commerce.discount.edit` | After discount detail view’s “Enabled” field.<br><small>[promotions/discounts/_edit.twig](https://github.com/craftcms/commerce/blob/4.x/src/templates/promotions/discounts/_edit.twig)</small>
10+
| `cp.commerce.discounts.edit.content` | After discount detail view’s main content.<br><small>[promotions/discounts/_edit.twig](https://github.com/craftcms/commerce/blob/4.x/src/templates/promotions/discounts/_edit.twig)</small>
11+
| `cp.commerce.discounts.edit.details` | After discount detail view’s existing right sidebar details column.<br><small>[promotions/discounts/_edit.twig](https://github.com/craftcms/commerce/blob/4.x/src/templates/promotions/discounts/_edit.twig)</small>
12+
| `cp.commerce.discounts.edit` | Before discount detail view’s template blocks.<br><small>[promotions/discounts/_edit.twig](https://github.com/craftcms/commerce/blob/4.x/src/templates/promotions/discounts/_edit.twig)</small>
13+
| `cp.commerce.discounts.index` | After discounts index view’s main content.<br><small>[promotions/discounts/index.twig](https://github.com/craftcms/commerce/blob/4.x/src/templates/promotions/discounts/index.twig)</small>
14+
| `cp.commerce.order.edit` | Before order edit view’s template blocks.<br><small>[orders/_edit.twig](https://github.com/craftcms/commerce/blob/4.x/src/templates/orders/_edit.twig)</small>
15+
| `cp.commerce.order.edit.details` | After existing order edit view’s right sidebar details.<br><small>[orders/_edit.twig](https://github.com/craftcms/commerce/blob/4.x/src/templates/orders/_edit.twig)</small>
16+
| `cp.commerce.order.edit.main-pane` | After existing content within order edit view’s “Order Details” tab.<br><small>[orders/_edit.twig](https://github.com/craftcms/commerce/blob/4.x/src/templates/orders/_edit.twig)</small>
17+
| `cp.commerce.product.edit.content` | After product detail view’s custom fields.<br><small>[products/_edit.twig](https://github.com/craftcms/commerce/blob/4.x/src/templates/products/_edit.twig)</small>
18+
| `cp.commerce.product.edit.details` | After existing product detail view’s right sidebar details.<br><small>[products/_edit.twig](https://github.com/craftcms/commerce/blob/4.x/src/templates/products/_edit.twig)</small>
19+
| `cp.commerce.sales.edit.content` | After sale detail view’s main content.<br><small>[promotions/sales/_edit.twig](https://github.com/craftcms/commerce/blob/4.x/src/templates/promotions/sales/_edit.twig)</small>
20+
| `cp.commerce.sales.edit.details` | After sale detail view’s existing right sidebar details column.<br><small>[promotions/sales/_edit.twig](https://github.com/craftcms/commerce/blob/4.x/src/templates/promotions/sales/_edit.twig)</small>
21+
| `cp.commerce.sales.edit` | Before sale detail view’s template blocks.<br><small>[promotions/sales/_edit.twig](https://github.com/craftcms/commerce/blob/4.x/src/templates/promotions/sales/_edit.twig)</small>
22+
| `cp.commerce.sales.index` | After sales index view’s main content.<br><small>[promotions/sales/index.twig](https://github.com/craftcms/commerce/blob/4.x/src/templates/promotions/sales/index.twig)</small>
23+
| `cp.commerce.subscriptions.edit.content` | After the last `.pane` in subscription detail view’s content block.<br><small>[subscriptions/_edit.twig](https://github.com/craftcms/commerce/blob/4.x/src/templates/subscriptions/_edit.twig)</small>
24+
| `cp.commerce.subscriptions.edit.meta` | After the discount detail view’s existing right sidebar details.<br><small>[subscriptions/_edit.twig](https://github.com/craftcms/commerce/blob/4.x/src/templates/subscriptions/_edit.twig)</small>

docs/commerce/4.x/orders-carts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fetch('/actions/commerce/cart/get-cart', {
6262

6363
Either of the examples above will generate a new cart _cookie_ if none exists. However, Commerce will only create an order element when a change is made to the cart—this prevents runaway creation of empty carts for guests or bots who happen to request a page that displays some cart information like the current item quantity or total.
6464

65-
To see what cart information you can use in your templates, take a look at the [Order](commerce4:craft\commerce\elements\Order) class reference. You can also see sample Twig in the example templates’ [`shop/cart/index.twig`](https://github.com/craftcms/commerce/blob/main/example-templates/dist/shop/cart/index.twig).
65+
To see what cart information you can use in your templates, take a look at the [Order](commerce4:craft\commerce\elements\Order) class reference. You can also see sample Twig in the example templates’ [`shop/cart/index.twig`](https://github.com/craftcms/commerce/blob/4.x/example-templates/dist/shop/cart/index.twig).
6666

6767
<toggle-tip title="Example Order">
6868

@@ -250,7 +250,7 @@ You can remove a line item by including a `remove` parameter in the request. Thi
250250
```
251251

252252
::: tip
253-
The [example templates](example-templates.md) include a [detailed cart template](https://github.com/craftcms/commerce/blob/main/example-templates/dist/shop/cart/index.twig) for adding and updating items in a full checkout flow.
253+
The [example templates](example-templates.md) include a [detailed cart template](https://github.com/craftcms/commerce/blob/4.x/example-templates/dist/shop/cart/index.twig) for adding and updating items in a full checkout flow.
254254
:::
255255

256256
#### Options Uniqueness
@@ -600,7 +600,7 @@ This will set temporarily the order’s calculation mode to *Recalculate All* an
600600

601601
### Order Notices
602602

603-
Notices are added to an order whenever it changes, whether it’s the customer saving the cart or a store manager recalculating from the control panel. Each notice is an [OrderNotice](https://github.com/craftcms/commerce/blob/main/src/models/OrderNotice.php) model describing what changed and could include the following:
603+
Notices are added to an order whenever it changes, whether it’s the customer saving the cart or a store manager recalculating from the control panel. Each notice is an [OrderNotice](https://github.com/craftcms/commerce/blob/4.x/src/models/OrderNotice.php) model describing what changed and could include the following:
604604

605605
- A previously-valid coupon or shipping method was removed from the order.
606606
- A line item’s purchasable was no longer available so that line item was removed from the cart.

docs/commerce/4.x/pdfs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ You’ll need to enter a few details:
1919
- **Name** is whatever you’d like to call the PDF in the control panel.
2020
- **Handle** is a reference to be used in templates.
2121
- **Description** is an optional note for explaining the template’s layout or purpose.
22-
- **PDF Template Path** should point to the Twig template that should be used for rendering the PDF file. (Add the [receipt example template](https://github.com/craftcms/commerce/blob/main/example-templates/dist/shop/_private/receipt/index.twig) here if you’d like to see one in action.)
22+
- **PDF Template Path** should point to the Twig template that should be used for rendering the PDF file. (Add the [receipt example template](https://github.com/craftcms/commerce/blob/4.x/example-templates/dist/shop/_private/receipt/index.twig) here if you’d like to see one in action.)
2323
- **Order PDF Filename Format** determines what the generated filename should look like. It can include tags for outputting order properties such as `{number}` or `{myOrderCustomField}`. (A `.pdf` extension will automatically be appended so you don’t need to add it here.)
2424
- **Language** lets you designate the language to be used when the PDF is rendered. It defaults to “The language the order was made in”, and a dropdown first lists site languages and then those available to the system.
2525
- **Enabled?** can be used to quickly toggle the PDF and control whether it’s available and sent in emails configured to use it.
@@ -43,7 +43,7 @@ Create a new [order status email](emails.md) or select an existing one. You’ll
4343

4444
## Creating PDF Templates
4545

46-
It might be easiest to start by modifying the [example receipt template](https://github.com/craftcms/commerce/blob/main/example-templates/dist/shop/_private/receipt/index.twig), previewing it in a browser for convenience until things are mostly as you’d like them.
46+
It might be easiest to start by modifying the [example receipt template](https://github.com/craftcms/commerce/blob/4.x/example-templates/dist/shop/_private/receipt/index.twig), previewing it in a browser for convenience until things are mostly as you’d like them.
4747

4848
Avoid extending your regular site layouts for PDF templates, since your site most likely includes references to scripts and styles that may cause issues with PDF conversion.
4949

0 commit comments

Comments
 (0)