Shopify API Function Documentation

Get All Referral Codes

Description: This function retrieves all available referral codes from the API endpoint and logs the response or errors to the console.

How to Use:

  1. Copy and paste the function into your JavaScript file or console.
  2. Call the function getAllReferralCodes() without any parameters.
  3. Check the console for the list of referral codes or errors.

Expected Output:


function getAllReferralCodes() {
    $.ajax({
        url: "https://webapppark.com/clients_work/wallet-connect-backend/api/shopify/referral-codes",
        method: "GET",
        success: function (response) {
            console.log("Referral Codes Retrieved Successfully:", response);
        },
        error: function (xhr, status, error) {
            console.error("Error Fetching Referral Codes:", xhr.responseText);
        },
    });
}

// Example usage:
// getAllReferralCodes();
                

Verify Referral Code

Description: This function verifies if a referral code is valid by sending it to the API endpoint.

How to Use:

  1. Copy and paste the function into your JavaScript file or console.
  2. Call the function verifyReferralCode(referralCode), replacing referralCode with the referral code to verify.
  3. Check the console for the verification result or errors.

Expected Output:


function verifyReferralCode(referralCode) {
    if (!referralCode) {
        console.error("Referral code is required!");
        return;
    }

    $.ajax({
        url: "https://webapppark.com/clients_work/wallet-connect-backend/api/shopify/verify-referral-code",
        method: "POST",
        contentType: "application/json",
        data: JSON.stringify({ referral_code: referralCode }),
        success: function (response) {
            console.log("Referral Code Verified Successfully:", response);
        },
        error: function (xhr, status, error) {
            console.error("Error Verifying Referral Code:", xhr.responseText);
        },
    });
}

// Example usage:
// verifyReferralCode("FDX1726JSN");
                

Get Product Info

Description: This function retrieves the complete product information, including the available stock, from the API endpoint.

How to Use:

  1. Copy and paste the function into your JavaScript file or console.
  2. Call the function getProductInfo() without any parameters.
  3. Check the console for the product information or errors.

Expected Output:


function getProductInfo() {
    $.ajax({
        url: "https://webapppark.com/clients_work/wallet-connect-backend/api/shopify/product-info",
        method: "GET",
        success: function (response) {
            console.log("Product Info Retrieved Successfully:", response);
        },
        error: function (xhr, status, error) {
            console.error("Error Fetching Product Info:", xhr.responseText);
        },
    });
}

// Example usage:
// getProductInfo();
                

Create Cart Checkout

Description: This function creates a cart checkout for a single product quantity, with an optional referral code.

How to Use:

  1. Copy and paste the function into your JavaScript file or console.
  2. Call the function createCartCheckout(quantity, referralCode), where:
    • quantity: The number of items for checkout (required).
    • referralCode: The referral code to apply (optional).
  3. Check the console for the checkout URL or errors.

Expected Output:


function createCartCheckout(quantity, referralCode) {
    if (!quantity || quantity <= 0) {
        console.error("Valid quantity is required!");
        return;
    }

    const payload = { quantity: quantity };
    if (referralCode) payload.referral_code = referralCode;

    $.ajax({
        url: "https://webapppark.com/clients_work/wallet-connect-backend/api/shopify/create-checkout",
        method: "POST",
        contentType: "application/json",
        data: JSON.stringify(payload),
        success: function (response) {
            console.log("Cart Checkout Created Successfully:", response);
        },
        error: function (xhr, status, error) {
            console.error("Error Creating Cart Checkout:", xhr.responseText);
        },
    });
}

// Example usage:
// createCartCheckout(1, "FDX1726JSN");
// createCartCheckout(1);