Skip to content

Commit cacfac3

Browse files
authored
Add new TYP target: purchase.thank-you.announcment.render (#3012)
Part of shop/issues-checkout#5935 ### Background This PR adds a new extension target for the Thank You page, allowing developers to render dismissable announcements at the top of the page. ### Solution Added a new extension target called `purchase.thank-you.announcement.render` that renders a dismissable announcement on the Thank You page. This provides developers with another way to communicate important information to customers after they complete their purchase. The implementation includes: - Adding the target definition to the `RenderExtensionTargets` interface - Creating documentation for the new target - Adding example implementations in both JS and React (TSX) formats - Updating the helper docs to include the new examples ### 🎩 - Create a new extension using the `purchase.thank-you.announcement.render` target - Complete a checkout flow to verify the announcement appears correctly on the Thank You page - Verify the announcement is dismissable ### Checklist - [ ] I have 🎩'd these changes - [ ] I have updated relevant documentation
2 parents 258fdd1 + cbb2c96 commit cacfac3

File tree

6 files changed

+152
-0
lines changed

6 files changed

+152
-0
lines changed

.changeset/clever-olives-hang.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/ui-extensions': minor
3+
---
4+
5+
Add Checkout Thank You page announcement extension target
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import {
2+
BlockStack,
3+
Button,
4+
InlineStack,
5+
Link,
6+
Modal,
7+
TextField,
8+
Text,
9+
extension,
10+
} from '@shopify/ui-extensions/checkout';
11+
12+
export default extension(
13+
'purchase.thank-you.announcement.render',
14+
(root, {shop}) => {
15+
const modalFragment = root.createFragment();
16+
modalFragment.appendChild(
17+
root.createComponent(
18+
Modal,
19+
{
20+
title:
21+
'Tell us about your shopping experience',
22+
padding: true,
23+
},
24+
[
25+
root.createComponent(
26+
BlockStack,
27+
undefined,
28+
[
29+
root.createComponent(
30+
Text,
31+
undefined,
32+
`We'd love to hear about your shopping experience at ${shop.name}`,
33+
),
34+
root.createComponent(TextField, {
35+
multiline: 4,
36+
label:
37+
'How can we make your shopping experience better?',
38+
}),
39+
root.createComponent(
40+
Button,
41+
undefined,
42+
'Submit',
43+
),
44+
],
45+
),
46+
],
47+
),
48+
);
49+
50+
root.appendChild(
51+
root.createComponent(
52+
InlineStack,
53+
undefined,
54+
[
55+
root.createComponent(
56+
Text,
57+
undefined,
58+
'Check our latest offers',
59+
),
60+
root.createComponent(
61+
Link,
62+
{
63+
overlay: modalFragment,
64+
},
65+
'Fill out the survey',
66+
),
67+
],
68+
),
69+
);
70+
},
71+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import {
2+
BlockStack,
3+
Button,
4+
InlineStack,
5+
Link,
6+
Modal,
7+
reactExtension,
8+
TextField,
9+
Text,
10+
useApi,
11+
} from '@shopify/ui-extensions-react/checkout';
12+
13+
// 1. Choose an extension target
14+
export default reactExtension(
15+
'purchase.thank-you.announcement.render',
16+
() => <Extension />,
17+
);
18+
19+
function Extension() {
20+
// 2. Use the extension API to gather context from the shop
21+
const {shop} = useApi();
22+
23+
// 3. Render a UI
24+
return (
25+
<InlineStack>
26+
<Text>Check our latest offers</Text>
27+
<Link
28+
overlay={
29+
<Modal
30+
title="Tell us about your shopping experience"
31+
padding
32+
>
33+
<BlockStack>
34+
<Text>
35+
We'd love to hear about your
36+
shopping experience at {shop.name}
37+
</Text>
38+
<TextField
39+
multiline={4}
40+
label="How can we make your shopping experience better?"
41+
></TextField>
42+
<Button>Submit</Button>
43+
</BlockStack>
44+
</Modal>
45+
}
46+
>
47+
Fill out the survey
48+
</Link>
49+
</InlineStack>
50+
);
51+
}

packages/ui-extensions/docs/surfaces/checkout/reference/helper.docs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ export function getExamples(
152152
...createExample('purchase.thank-you.footer.render-after/default'),
153153
...createExample('purchase.checkout.chat.render/default'),
154154
...createExample('purchase.thank-you.chat.render/default'),
155+
...createExample('purchase.thank-you.announcement.render/default'),
155156
'analytics-publish': {
156157
description:
157158
'You can publish analytics events to the Shopify analytics frameworks and they will be propagated to all web pixels on the page.',
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
2+
3+
import {getExample, getLinksByTag, THANK_YOU_API} from '../helper.docs';
4+
5+
const data: ReferenceEntityTemplateSchema = {
6+
name: 'purchase.thank-you.announcment.render',
7+
description: `A static extension target that is rendered on top of the **Thank you page** as a dismissable announcement.`,
8+
defaultExample: getExample('purchase.thank-you.announcement.render/default', [
9+
'jsx',
10+
'js',
11+
]),
12+
related: getLinksByTag('targets'),
13+
...THANK_YOU_API,
14+
};
15+
16+
export default data;

packages/ui-extensions/src/surfaces/checkout/targets.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,14 @@ export interface RenderExtensionTargets {
647647
OrderConfirmationApi & StandardApi<'purchase.thank-you.chat.render'>,
648648
AllowedComponents<'Chat'>
649649
>;
650+
/**
651+
* A static extension target that is rendered on top of the **Thank you page** as a dismissable announcement.
652+
*/
653+
'purchase.thank-you.announcement.render': RenderExtension<
654+
OrderConfirmationApi &
655+
StandardApi<'purchase.thank-you.announcement.render'>,
656+
AnyComponent
657+
>;
650658
}
651659

652660
export interface RunnableExtensionTargets {

0 commit comments

Comments
 (0)