@builder.io/plugin-commercelayer 0.0.3-0 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,18 +1,35 @@
1
- # Builder.io CommerceLayer plugin
1
+ # Builder.io Commerce Layer Plugin
2
2
 
3
- Easily connect your CommerceLayer APIs to your Builder.io content!
3
+ Easily connect your Commerce Layer products to your Builder.io content!
4
4
 
5
5
  ## Installation
6
6
 
7
- Go to [builder.io/account/organization](https://builder.io/account/organization) and type `@builder.io/plugin-commercelayer` , then hit save, a prompt will ask you for your Client ID / Client Secret.
7
+ Go to [builder.io/account/organization](https://builder.io/account/organization) and press on `@builder.io/plugin-commercelayer` in the list of plugins, then hit save. You'll be prompted for your Commerce Layer credentials:
8
+ - Client ID
9
+ - Market Scope (e.g., 'market:id:YOUR_MARKET_ID')
8
10
 
9
- ![Installation screenshot](https://cdn.builder.io/api/v1/image/assets%2F6d39f4449e2b4e6792a793bb8c1d9615%2F18a7201313914cccae7f0311a1a614ae)
11
+ ## Features
10
12
 
11
- You will now see three new field types (for [model](https://builder.io/c/docs/guides/getting-started-with-models) fields, [symbol](https://builder.io/c/docs/guides/symbols) inputs, [custom components](https://builder.io/c/docs/custom-react-components) fields), and [custom targeting attributes](https://www.builder.io/c/docs/guides/targeting-and-scheduling#custom-targeting) that can be used in three different contexts:
13
+ The plugin provides new field types for your Builder.io models:
12
14
 
13
- ### Custom targeting
15
+ ### Product Fields
14
16
 
15
- Custom targeting in Builder.io allow users to target content by a multitude of attributes, and in this plugin you'll be able to add specific content to CommerceLayer products, for this you'll need first to set the target attributes on the host site, either by setting the `userAttributes` if you're rendering client side:
17
+ - `Commerce Layer Product` - Search and select products from your Commerce Layer catalog
18
+ - `Commerce Layer Product Preview` - Preview product templates with live data
19
+
20
+ ### Component Model Fields
21
+
22
+ Component models can be used to create product page templates. Using the following fields makes previewing the templates straightforward:
23
+
24
+ - `Commerce Layer Product Preview` can be used as a custom field on component models to create templated editing URLs. For example:
25
+ ```
26
+ https://www.mystore.com/product/${previewProduct.handle}
27
+ ```
28
+ Add a custom field of type `Commerce Layer Product Preview` to dynamically update the preview URL based on the selected product.
29
+
30
+ ### Custom Targeting
31
+
32
+ You can target content to specific products by setting the target attributes on your site:
16
33
 
17
34
  ```ts
18
35
  builder.setUserAttributes({
@@ -20,32 +37,7 @@ builder.setUserAttributes({
20
37
  });
21
38
  ```
22
39
 
23
- Or by passing it as a query param to the [content API](https://www.builder.io/c/docs/query-api#:~:text=userAttributes) call, or in [graqhql query](https://www.builder.io/c/docs/graphql-api#:~:text=with%20targeting) for e.g in Gatsby or nextjs.
24
-
25
- - `CommerceLayer Product` when used as a custom targeting type, it'll target contexts where the field is set to the product ID, you'll need to set the product ID on the host environment, using one of the methods above. Alternatively, if you want to target by product handle (slug) use the `CommerceLayer Product Handle` type in your custom targeting attributes.
26
-
27
- ### Symbol Inputs
28
-
29
- Using the field types `CommerceLayer Product` as inputs, the UIs will prompt to search for products. When consumed by APIs, SDKs, or in the Builder.io UIs, the value will be resolved automatically the in the form of a Builder.io `Request` object
30
-
31
- ```js
32
- {
33
- "yourFieldName": {
34
- "@type": "@builder.io/core:Request",
35
- "request": {
36
- "url": "..."
37
- },
38
- "data": {
39
- // Response data from the API request, e.g.:
40
- "product": {
41
- /* ... */
42
- }
43
- }
44
- }
45
- }
46
- ```
47
-
48
- ## How to develop?
40
+ ## Development
49
41
 
50
42
  ### Install
51
43
 
@@ -61,26 +53,30 @@ npm install
61
53
  npm start
62
54
  ```
63
55
 
64
- ### Add the plugin in Builder.io
56
+ ### Add the Plugin Locally
65
57
 
66
58
  Go to [builder.io/account/organization](https://builder.io/account/organization) and add the localhost URL to the plugin from the plugin settings (`http://localhost:1268/plugin.system.js?pluginId=@builder.io/plugin-commercelayer`)
67
59
 
68
- **NOTE:** Loading `http://` content on an `https://` website will give you a warning. Be sure to click the shield in the top right of your browser and choose "load unsafe scripts" to allow the HTTP content on Builder's HTTPS site when developing locally
69
-
70
- <img alt="Load unsafe script example" src="https://i.stack.imgur.com/uSaLL.png">
60
+ **NOTE:** Loading http:// content on an https:// website will give you a warning. Click the shield in the top right of your browser and choose "load unsafe scripts" to allow http content on Builder's https site when developing locally.
71
61
 
72
- Now as you develop you can restart Builder to see the latest version of your plugin.
62
+ ### Testing the Plugin
73
63
 
74
- To uninstall your plugin,remove it in the plugins UI
64
+ 1. Create a custom [model](https://builder.io/c/docs/guides/getting-started-with-models)
65
+ 2. Add a Commerce Layer Product field
66
+ 3. Search and select products from your catalog
67
+ 4. Preview the content with live product data
75
68
 
76
- ### Seeing the plugin in action
69
+ ## Authentication
77
70
 
78
- Try creating a custom [model](https://builder.io/c/docs/guides/getting-started-with-models), [component](https://builder.io/c/docs/custom-react-components), or [symbol](https://builder.io/c/docs/guides/symbols) using an CommerceLayer field, and edit away!
71
+ The plugin uses Commerce Layer's Sales Channel authentication. You'll need:
72
+ - A Commerce Layer account
73
+ - Sales Channel API credentials
74
+ - A valid market scope
79
75
 
80
- <img src="https://i.imgur.com/uVOLn7A.gif" alt="Seeing your plugin in the editor example gif">
76
+ ## Contributing
81
77
 
82
- ### Frameworks
78
+ Contributions are welcome! Please read Builder.io's [contributing guidelines](https://github.com/BuilderIO/builder/blob/main/CONTRIBUTING.md) before submitting PRs.
83
79
 
84
- Builder.io uses [React](https://github.com/facebook/react) and [Material UI](https://github.com/mui-org/material-ui) for the UI, and [Emotion](https://github.com/emotion-js/emotion) for styling.
80
+ ## Frameworks
85
81
 
86
- Using these frameworks in Builder plugins ensures a better experience and performance.
82
+ Builder.io uses [React](https://github.com/facebook/react) and [Material UI](https://github.com/mui-org/material-ui) for the UI, and [Emotion](https://github.com/emotion-js/emotion) for styling.