Remove from Wishlist
Removes the product from wishlist
Description
The removeFromWishlist action removes a specific product from the logged-in customer’s wishlist.
It helps users manage their saved items by deleting products they no longer wish to keep.
Function Signature
VajroSDK.actions.removeFromWishlist({productId: "1234234342", variantId: "28736487623", id: "876234876234"})Parameter | Type | Required | Description |
|---|---|---|---|
productId | String | Yes | Unique ID of the Product available in Shopify |
variantId | String | Yes | Unique ID of the variant available in Shopify |
id | String | Yes | ID of the wishlist created in the app |
Structure of Response
| Status | Response |
|---|---|
| Success | { "status": "success", "message": "Removed from Wishlist" } |
| Invalid Product Id | { "status": "error", "errorId": 400, "errorHandle": "invalid-product-Id", "message": "The product id is invalid" } |
| Not in Wishlist | { "status": "error", "errorId": 400, "errorHandle": "not-in-wishlist", "message": "The product is currently not in wishlist" } |
| Unexpected Error | { "status": "error", "errorId": 500, "errorHandle": "unknown-error", "message": "Something unexpected happened" } |
Example Usage
const btnWishlist = document.getElementById("remove-from-wishlist");
function getWishlistEntry() {
const product = VajroSDK.variables.product;
const variant = product?.selectedVariant;
const wishlistedProducts =
VajroSDK.variables.customer?.wishlistedProducts || [];
return wishlistedProducts.find(
(item) =>
String(item.productId) === String(product?.id) ||
String(item.variantId) === String(variant?.id)
);
}
btnWishlist.addEventListener("click", async () => {
const product = VajroSDK.variables.product;
const variant = product?.selectedVariant;
const entry = getWishlistEntry();
const isWishlisted = !!entry;
if (isWishlisted) {
// 🗑️ Remove existing wishlist item
await VajroSDK.actions.removeFromWishlist({
productId: entry.productId,
variantId: entry.variantId,
id: entry.id,
});
}
});<button id="remove-from-wishlist">Remove from Wishlist</button>Best Practices
- Sync UI dynamically: Update icons or list items immediately upon removal.
- Use confirmation for bulk deletes: Prevent accidental removals.
- Leverage listeners: Combine with wishlistUpdated for auto-refresh of wishlist count or content.
- Graceful handling: Always handle Promise rejection for network or authentication failures.
- Combine with analytics: Track wishlist removals to improve recommendation accuracy.
Caveats
- Requires login: Only works for authenticated customers.
- App-only: Available exclusively in the Superfans mobile app environment.
- Asynchronous: Always await or handle .then()/.catch() for smoother UI flow.
- No undo: Once removed, an item must be re-added manually.
Updated about 1 month ago