Description: This function retrieves all available referral codes from the API endpoint and logs the response or errors to the console.
How to Use:
getAllReferralCodes() without any parameters.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();
Description: This function verifies if a referral code is valid by sending it to the API endpoint.
How to Use:
verifyReferralCode(referralCode), replacing referralCode with the referral code to verify.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");
Description: This function retrieves the complete product information, including the available stock, from the API endpoint.
How to Use:
getProductInfo() without any parameters.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();
Description: This function creates a cart checkout for a single product quantity, with an optional referral code.
How to Use:
createCartCheckout(quantity, referralCode), where:
quantity: The number of items for checkout (required).referralCode: The referral code to apply (optional).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);