@shopify/ui-extensions
Advanced tools
Comparing version 0.0.0-unstable-20230307212523 to 0.0.0-unstable-20230321144342
@@ -5,8 +5,5 @@ import type { StandardApi } from '../standard/standard'; | ||
type CustomerSegmentationFeature = 'productsPurchasedByTags' | 'aggregateFilters'; | ||
type TemplateCategory = 'all' | 'firstTimeBuyers' | 'highValueCustomers' | 'reEngageCustomers' | 'abandonedCheckout' | 'purchaseBehaviour' | 'location'; | ||
export interface CustomerSegmentationTemplateApi<ExtensionPoint extends AnyExtensionPoint> extends StandardApi<ExtensionPoint> { | ||
i18n: I18n; | ||
/** @private */ | ||
__category: TemplateCategory; | ||
/** @private */ | ||
__enabledFeatures: CustomerSegmentationFeature[]; | ||
@@ -13,0 +10,0 @@ } |
type Source = 'categoriesMajor' | 'firstVisitMajor' | 'heartMajor' | 'marketingMajor' | 'checkoutMajor' | 'ordersMajor' | 'locationMajor' | 'emailNewsletterMajor' | 'firstOrderMajor' | 'billingStatementDollarMajor' | 'diamondAlertMajor' | 'abandonedCartMajor' | 'calendarMajor' | 'productsMajor' | 'globeMajor' | 'flagMajor' | 'uploadMajor' | 'buyButtonMajor' | 'followUpEmailMajor'; | ||
type TemplateCategory = 'firstTimeBuyers' | 'highValueCustomers' | 'reEngageCustomers' | 'abandonedCheckout' | 'purchaseBehaviour' | 'location'; | ||
/** | ||
@@ -15,2 +16,3 @@ * Reserved namespace and key for the customer standard metafield used in the template's query. | ||
dateAdded?: Date; | ||
category?: TemplateCategory; | ||
} | ||
@@ -17,0 +19,0 @@ /** |
{ | ||
"name": "@shopify/ui-extensions", | ||
"version": "0.0.0-unstable-20230307212523", | ||
"version": "0.0.0-unstable-20230321144342", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "module": "index.mjs", |
@@ -12,11 +12,2 @@ import type {StandardApi} from '../standard/standard'; | ||
type TemplateCategory = | ||
| 'all' | ||
| 'firstTimeBuyers' | ||
| 'highValueCustomers' | ||
| 'reEngageCustomers' | ||
| 'abandonedCheckout' | ||
| 'purchaseBehaviour' | ||
| 'location'; | ||
export interface CustomerSegmentationTemplateApi< | ||
@@ -28,5 +19,3 @@ ExtensionPoint extends AnyExtensionPoint, | ||
/** @private */ | ||
__category: TemplateCategory; | ||
/** @private */ | ||
__enabledFeatures: CustomerSegmentationFeature[]; | ||
} |
@@ -24,2 +24,10 @@ import {createRemoteComponent} from '@remote-ui/core'; | ||
type TemplateCategory = | ||
| 'firstTimeBuyers' | ||
| 'highValueCustomers' | ||
| 'reEngageCustomers' | ||
| 'abandonedCheckout' | ||
| 'purchaseBehaviour' | ||
| 'location'; | ||
/** | ||
@@ -46,2 +54,6 @@ * Reserved namespace and key for the customer standard metafield used in the template's query. | ||
dateAdded?: Date; | ||
/* The category in which the template will be visible. | ||
When provided, the template will show in its respective category and aggregate sections. | ||
When missing, the template will show in the aggregate sections only */ | ||
category?: TemplateCategory; | ||
} | ||
@@ -48,0 +60,0 @@ |
@@ -8,34 +8,31 @@ import { | ||
'admin.customers.segmentation-templates.render', | ||
(root, {i18n, __category, __enabledFeatures}) => { | ||
if (__category === 'reEngageCustomers') { | ||
const productsPurchasedOnTagsEnabled = __enabledFeatures.includes('productsPurchasedByTags'); | ||
const productTemplate = root.createComponent(CustomerSegmentationTemplate, { | ||
title: i18n.translate('product.title'), | ||
description: i18n.translate('product.description'), | ||
icon: 'productsMajor', | ||
templateQuery: productsPurchasedOnTagsEnabled | ||
? 'products_purchased(tag: (product_tag)) = true' | ||
: 'products_purchased(id: (product_id)) = true', | ||
templateQueryToInsert: productsPurchasedOnTagsEnabled | ||
? 'products_purchased(tag:' | ||
: 'products_purchased(id:', | ||
dateAdded: new Date('2023-01-15') | ||
}); | ||
(root, {i18n, __enabledFeatures}) => { | ||
const productsPurchasedOnTagsEnabled = __enabledFeatures.includes('productsPurchasedByTags'); | ||
const productTemplate = root.createComponent(CustomerSegmentationTemplate, { | ||
title: i18n.translate('product.title'), | ||
description: i18n.translate('product.description'), | ||
icon: 'productsMajor', | ||
templateQuery: productsPurchasedOnTagsEnabled | ||
? 'products_purchased(tag: (product_tag)) = true' | ||
: 'products_purchased(id: (product_id)) = true', | ||
templateQueryToInsert: productsPurchasedOnTagsEnabled | ||
? 'products_purchased(tag:' | ||
: 'products_purchased(id:', | ||
dateAdded: new Date('2023-01-15'), | ||
category: 'reEngageCustomers' | ||
}); | ||
root.appendChild(productTemplate); | ||
} | ||
const locationTemplate = root.createComponent(CustomerSegmentationTemplate, { | ||
title: i18n.translate('location.title'), | ||
description: [i18n.translate('location.firstParagraph'), i18n.translate('location.secondParagraph')], | ||
icon: 'locationMajor', | ||
templateQuery: "customer_cities CONTAINS 'US-NY-NewYorkCity'", | ||
category: 'location' | ||
}); | ||
if (__category === 'location') { | ||
const locationTemplate = root.createComponent(CustomerSegmentationTemplate, { | ||
title: i18n.translate('location.title'), | ||
description: [i18n.translate('location.firstParagraph'), i18n.translate('location.secondParagraph')], | ||
icon: 'locationMajor', | ||
templateQuery: "customer_cities CONTAINS 'US-NY-NewYorkCity'", | ||
}); | ||
root.appendChild(productTemplate); | ||
root.appendChild(locationTemplate); | ||
root.appendChild(locationTemplate); | ||
} | ||
root.mount(); | ||
}, | ||
); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1170587
13611