Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dlerm/shopify-wishlist-app

💚 A Shopify Wishlist App back-end that can be used in addition to the Shopify Wishlist theme files.
https://github.com/dlerm/shopify-wishlist-app

api app backend express javascript metafields node shopify wishlist

Last synced: 7 days ago
JSON representation

💚 A Shopify Wishlist App back-end that can be used in addition to the Shopify Wishlist theme files.

Awesome Lists containing this project

README

        

# Shopify Wishlist App

A Shopify Wishlist App that can be used seamlessly with the [Shopify Wishlist](https://github.com/dlerm/shopify-wishlist) theme files.

### Overview
This is a back-end solution meant for usage as a Shopify private app. The app saves customer wishlists into metafields to avoid the need for an external data store.

### How It Works
The app creates & updates a customer metafield that stores a string list of product handles (comma separated).

|Metafield | Value |
|----------|-------|
|customer.metafields.shopify_wishlist_app.wishlist|"product-handle-1,product-handle2,..."

The front-end can make requests to the app's endpoints to fetch, create, update or delete a wishlist.

### How To Use

1. Host this app on a server of your choice
2. Setup your server's environment variables
3. Query the app endpoints (via Javascript) from your Shopify theme to display or manipulate a customer's wishlist

##### ENV Setup
```
# Origins/URLs that are allowed to make App/API requests
# Inlcude the http/https protocols
# Comma separated for multiple origins
ALLOWED_ORIGINS=https://customer-wishlist.myshopify.com

# The "myshopify" domain without the "myshopify.com" ending
SHOPIFY_DOMAIN=customer-wishlist

# Shopify private app key
API_KEY=xxxxxxxxxxxxxxxxxxx

# Shopify private app password/secret
API_PASSWORD=xxxxxxxxxxxxxxxxxxx
```

### Request Endpoints

All endpoints require a single `:id` parameter in the URL which should represent a unique Shopify customer ID. Each request type may have extra data needed to fulfill the request, see below.

##### GET `/wishlist/:id`
---
**Query Parameters**
|Name|Required|Description|
|----:|:----:|----|
|format|optional|The format of the wishlist items to be returned.

Supported value: `product`

By default the wishlist will be returned as an `Array` representing the product handles. Supplying the value `product` will return the wishlist as an `Array` representing the full [Shopify product JSON](https://shopify.dev/api/admin-rest/2021-10/resources/product#[get]/admin/api/2021-10/products/{product_id}.json). |

**Response (Default)**
```
{
"id": ,
"wishlist": [
"",
"",
...
],
"metafield": {
"id": ,
"namespace": "shopify_wishlist_app",
"key": "wishlist",
"value": ",,...",
"value_type": "string",
"description": null,
"owner_id": ,
"created_at": ,
"updated_at":
"owner_resource": "customer",
"admin_graphql_api_id": "gid://shopify/Metafield/"
},
"status": {
"message": "OK",
"code": 200
}
}
```
**Response (Format: `product`)**

[Only displaying the `wishlist` response key for brevity]
```
{
"wishlist": [
{ },
{ },
...
],
...
}
```

##### POST `/wishlist/:id`
---
**Body Parameters**
|Name|Required|Description|
|----:|:----:|----|
|handle|required|The Shopify product handle that should be added/removed from the wishlist.

This endpoint acts as a toggle. If the requested handle does not currently exist in the wishlist, add it, otherwise remove it.|

**Response**
```
{
"metafield": {
"namespace": "shopify_wishlist_app",
"key": "wishlist",
"value_type": "string",
"value": ",,..."
},
"status": {
"message": "OK",
"code": 200
}
}
```
##### DELETE `/wishlist/:id`
---
**Parameters** - None

**Response**
```
{
"metafield": {},
"status": {
"message": "OK",
"code": 200
}
}
```