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
ID of the wishlist can be retrieved from variable - Customer

Structure of Response

StatusResponse
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

  1. Sync UI dynamically: Update icons or list items immediately upon removal.
  2. Use confirmation for bulk deletes: Prevent accidental removals.
  3. Leverage listeners: Combine with wishlistUpdated for auto-refresh of wishlist count or content.
  4. Graceful handling: Always handle Promise rejection for network or authentication failures.
  5. Combine with analytics: Track wishlist removals to improve recommendation accuracy.

Caveats

  1. Requires login: Only works for authenticated customers.
  2. App-only: Available exclusively in the Superfans mobile app environment.
  3. Asynchronous: Always await or handle .then()/.catch() for smoother UI flow.
  4. No undo: Once removed, an item must be re-added manually.