// × Are you sure you want to delete ? No Yes `) } function deletePopupConfirm(prepaidFlag) { // Get the modal var appstleDeletePopupmodal = document.getElementById("appstle_popupModal"); jQuery('body').css('overflow', 'hidden') var appstleModalClose = document.getElementsByClassName("appstle_model_close")[0]; appstleDeletePopupmodal.style.display = "block"; // When the user clicks on (x), close the modal appstleModalClose.onclick = function() { hideDeleteConfirmPopup() } jQuery('.appstle_delete_model_nobtn').on('click', function(){ hideDeleteConfirmPopup() }) // When the user clicks anywhere outside of the modal, close it window.onclick = function(event) { if (event.target == appstleDeletePopupmodal) { hideDeleteConfirmPopup() } } } function hideDeleteConfirmPopup () { jQuery("#appstle_popupModal").remove(); appendDeletePopupBodyTag(); jQuery('body').css('overflow', 'unset') } function subscriptionInit(){ jQuery("body").off(); if(jQuery('[id=appstle_popupModal]').length > 0) { jQuery("#appstle_popupModal").remove(); } appendDeletePopupBodyTag(); jQuery(".appstle_myProduct").empty(); if (customerId != undefined && shopName != undefined) { let subscriptionUrl = "https://subscription-admin.appstle.com/api/subscription-customers/" + customerId + "?shop=" + shopName let validContractIdUrl = "https://subscription-admin.appstle.com/api/subscription-customers/valid/" + customerId + "?shop=" + shopName subscriptionRender(subscriptionUrl, validContractIdUrl, shopName, customerId, null); } else if (token!=null){ let subscriptionUrl = "https://subscription-admin.appstle.com/api/subscription-customers/" + token + "?shop=" + shopName let validContractIdUrl = "https://subscription-admin.appstle.com/api/subscription-customers/valid/" + token + "?shop=" + shopName subscriptionRender(subscriptionUrl, validContractIdUrl, shopName, null, token); } else { window.location.href = 'https://'+ shopName +'/account' } } function accordionToggle(ev) { // var acc = document.getElementsByClassName("accordion"); // var i; ev.classList.toggle("active"); var panel = ev.nextElementSibling; $(panel).slideToggle() } function toggleContractAccordian(el) { var selector = $(el).attr('data-accordian-selector') $(el).toggleClass("active"); $(selector).slideToggle() } function getDeviceType() { const ua = navigator.userAgent; if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(ua)) { return "tablet"; } if ( /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test( ua ) ) { return "mobile"; } return "desktop"; }; function appstle_adjust_container_height(imageEl) { } function updateSubtotal(selector) { var productEl = jQuery('#' + selector); var variantSelectField = productEl.find('select'); var currencyCode = productEl.attr('data-currency-code'); var qty = productEl.find('input').val(); if(parseInt(qty) 0) { var subscriptionContractData = result.subscriptionContracts.edges.sort(function (a, b) { if (a.node.status b.node.status) { return 1; } // names must be equal return 0; }); subscriptionContractData.forEach((subItem, index) => { var paymentData = subItem?.node?.customerPaymentMethod?.instrument; var paymentMethod = paymentData?.__typename; var contractId = subItem?.node?.id?.split('/')[4]; var frequencyIntervalTranslate = subItem?.node?.billingPolicy?.interval; if(frequencyIntervalTranslate == "WEEK") { frequencyIntervalTranslate = WeekText } else if(frequencyIntervalTranslate == "DAY") { frequencyIntervalTranslate = DayText } else if(frequencyIntervalTranslate == "MONTH") { frequencyIntervalTranslate = MonthText } else if(frequencyIntervalTranslate == "YEAR") { frequencyIntervalTranslate = YearText } // Check the contract id is valid or not if(validContractId?.length >0 && !validContractId?.includes(parseInt(contractId))) { return; } // Calling Contract Details API //var detailedContractData = contractDetailsFromContractId(contractId); jQuery.ajax({ async: false, type: "GET", url: 'https://subscription-admin.appstle.com/api/subscription-contracts/contract-external/' + contractId + '?shop=' +shopName, dataType: "json", headers: { 'Access-Control-Allow-Origin': '*', }, success: function (extResult, status, xhr) { if (paymentMethod === "CustomerCreditCard") { paymentMethod = creditcartText } let isPrepaidplan = true; if(extResult?.billingPolicy?.intervalCount == extResult?.deliveryPolicy?.intervalCount) { isPrepaidplan = false; } if (subItem.node.lines?.edges?.length == 1) { subItem.node.lines?.edges?.forEach(contractItem => { if (contractItem?.node?.productId == null) { var accordionSection = '' + ' ' + ' ' + ' ' + subscriptionNoText + ' - #' + subItem.node.id.split('/')[4] + '' + ' ' + ' ' + '' + contractItem.node.title + ' has been removed.' + ' ' + cancelAccordionTitle + '' + ' ' + ' ' + ' ' + ' ' + cancelSubscriptionBtnText + '' + ' ' + ' ' + ' ' + '' jQuery('.appstle_myProduct').append(accordionSection); } else { var subscriptionList = ' ' +' ' +' ' +' ' +' ' + subscriptionNoText + ' - #' + subItem.node.id.split('/')[4] + '' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + subItem.node.billingPolicy.intervalCount + ' ' + frequencyIntervalTranslate + ' ' + subscriptionNoText + '' +' ' + (subItem.node.status == "ACTIVE" ? activeBadgeText : (subItem.node.status === "CANCELLED" ? closedBadgeText : (subItem.node.status === "PAUSED" ? pauseBadgeText : "")) ) + '' +' ' +'' + ((subItem.node.status === "CANCELLED" || subItem.node.status === "PAUSED") ? '' : ('' +' ' +' ' + nextOrderText + ': ' +' ' +' ' + (new Date(subItem.node.nextBillingDate).toDateString()) + '' +' ' +' Processing.. Please Wait' +' ' +''+ ((changeNextOrderDateFlag == "true") ? ('' +' ' +' ') : '') + '' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + cancelChangeOrderBtnText + '' +' ' + updateChangeOrderBtnText + '' +' ' +' ' +' ')) + '' +'' + ((subItem.node.status === "CANCELLED") ? '' : ('' +' ' +' ' + orderFrequencyText + ': ' +' ' +' ' + subItem.node.billingPolicy.intervalCount + ' ' + frequencyIntervalTranslate + '' +' Processing.. Please Wait' +''+ ((subItem.node.status === "PAUSED") ? '' : ((changeOrderFrequencyFlag == "true") ? ('' +' ' +' ') : '')) + '' +' ' +' ' +' ' +' ' +' ' +' ' +' '+DayText+'' +' '+ WeekText + '' +' '+MonthText+'' +' '+YearText+'' +' ' +' ' +' ' +' ' + cancelFreqBtnText + '' +' ' + updateFreqBtnText + '' +' ' +' ' +' ')) + '' +' ' +' ' +' ' + productLabelText + '' +' ' +' ' +' ' +''+ ((pauseResumeSubscriptionFlag === "true") ? ((subItem.node.status === "ACTIVE") ? ('' +' ' +' ' +' ' +' ' +' ' + pauseSubscriptionText + '' +' ') : '') : '') + '' +''+ ((pauseResumeSubscriptionFlag === "true") ? ((subItem.node.status === "PAUSED") ? ('' +' ' +' ' +' ' +' ' +' ' + resumeSubscriptionText + '' +' ') : '') : '') + '' +'' + ((subItem.node.status === "CANCELLED" || subItem.node.status === "PAUSED") ? '' : ('' +' ' + seeMoreDetailsCta + '' +' ' + hideDetalsCta + '' +' ' +' ')) + '' +' ' +' ' +' ' + '' var addressDetails = extResult?.deliveryMethod?.address var accordionSection = ' ' +' ' +' ' +' ' + productAccordian + '' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + ShippingAccordianLabel + '' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + addressHeaderTitleText + '' +''+ ((changeShippingAddressFlag == "true") ? ('' +' ' +' ') : '') + '' +' ' +' ' +''+ ((addressDetails.firstName) ? ('' + addressDetails.firstName + '') : '') + ' ' + ((addressDetails.lastName) ? ('' + addressDetails.lastName + '') : '') + '' +''+ ((addressDetails.address1) ? ('' + addressDetails.address1 + '') : '') +''+ ((addressDetails.address2) ? ('' + addressDetails.address2 + '') : '') +''+ ((addressDetails.city) ? ('' + addressDetails.city + '') : '') +''+ ((addressDetails.province) ? (', ' + addressDetails.province + '') : '') +''+ ((addressDetails.country) ? (', ' + addressDetails.country + '') : '') +''+ ((addressDetails.zip) ? ('' + addressDetails.zip + '') : '') +''+ ((addressDetails.phone) ? ('' + addressDetails.phone + '') : '') +' ' +' ' +' ' +' ' +' ' +' ' + firstNameLabel + '' +' ' +' ' +' ' +' ' + lastNameLabel + '' +' ' +' ' +' ' +' ' + companyLabel + '' +' ' +' ' +' ' +' ' + phoneLabel + '' +' ' +' ' +' ' +' ' + address1Label + '' +' ' +' ' +' ' +' ' + address2Label + '' +' ' +' ' +' ' +' ' + cityLabel + '' +' ' +' ' +' ' +' ' + countryLabel + '' +' ' +' ' +' ' +' ' + provinceLabel + '' +' ' +' ' +' ' +' ' + zipLabel + '' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + cancelEditShippingBtnText + '' +' ' + updateEditShippingBtnText + '' +' ' +' ' +' ' +' ' +' ' + (isPrepaidplan ? upcomingFulfillmentAccordion : upcomingOrderAccordionTitle ) + ' ' + ' ' + ' ' + ' ' +' ' +' ' + paymentDetailAccordionTitle + '' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + paymentMethodTypeText + ': ' + paymentMethod + ' - ' + paymentData?.brand?.toUpperCase() + endingWithText + paymentData?.lastDigits + '' +' ' +' ' +' ' + cardHolderNameText + ': '+ paymentData?.name +'' +' ' +' ' +' ' + cardExpiryText + ': ' + paymentData?.expiryMonth + ' / ' + paymentData?.expiryYear + '' +' ' +' ' +' ' +' ' +' ' + updatePaymentBtnText + '' +' ' +' ' + paymentNotificationText + '' +' ' + '' + (!(shopName == "powerhouse-brewing-company.myshopify.com" && isPrepaidplan) ? ('' + cancelAccordionTitle + ' ') : '') + '' + ' ' + ' ' + ' ' + ' ' + cancelSubscriptionBtnText + ' ' + ' ' + ' ' + ' ' + ' ' jQuery('.appstle_myProduct').append(subscriptionList); jQuery('.appstle_myProduct').append(accordionSection); subItem.node.lines?.edges?.forEach((contractItem, idx) => { if (contractItem?.node?.productId != null) { var subscribedProduct = '' +' ' +' ' +' ' + contractItem.node?.title + ' - ' + contractItem?.node?.variantTitle + '' +' ' +' ' +' ' + quantityLbl + ': ' + contractItem.node?.quantity + '' +' ' + amountLbl + ': ' + contractItem.node?.lineDiscountedPrice?.amount + ' ' + contractItem.node?.lineDiscountedPrice?.currencyCode + '' +' ' + nextOrderText + ': ' + (new Date(subItem?.node?.nextBillingDate).toDateString()) + '' +' ' +' ' +' ' +' ' +' ' +' ' + editQuantityLabel + '' +' ' +' Please enter a valid number' +' ' +' ' +' Edit Variant' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + subTotalLabel + ': ' + contractItem.node?.lineDiscountedPrice?.amount + ' ' + contractItem.node?.lineDiscountedPrice?.currencyCode + '' +' ' + cancelButtonText + '' +' ' + updateButtonText + '' +' ' +' ' +' ' +''+ ((editProductFlag == "true") ? ('') : '') + '' +' ' +' ' +'' jQuery('#sub' + index).append(subscribedProduct) if (contractItem.node.variantTitle == null) { jQuery('.appstle_variantTitle_' + contractItem.node?.productId?.split('/')[4]).hide(); } jQuery('.appstle_subscription_contract_product_list_wrapper_' + contractId).append( '' + contractItem.node?.title + (contractItem?.node?.variantTitle ? (' - ' + contractItem?.node?.variantTitle) : '') + (contractItem.node?.quantity > 1 ? 'x ' + contractItem.node?.quantity + '' : '') + '' ) var imageElement = jQuery(''); jQuery('.appstle_subscription_contract_image_wrapper_' + contractId).append(imageElement); } else { var subscribedProduct = '' + ' ' + ' ' + contractItem.node?.title + ' has been removed' + ' ' + '' jQuery('#sub' + index).append(subscribedProduct) } }); if(shopName != "taelor-style-dev.myshopify.com" && (addAdditionalProductFlag == "true")) jQuery('#sub' + index).prepend('' + addProductButtonText + '' + addProductLabelText + '' + addProductButtonText + '' + cancelButtonText + '') if(isPrepaidplan) { result?.originOrder?.fulfillmentOrders?.edges?.map((orderItem) => { var upcomingOrder = '' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + nextOrderDateLbl + ': ' + (new Date(orderItem?.fulfillAt).toDateString()) + '' +' ' + (orderItem.status == "SKIPPED" ? skipBadgeText : queueBadgeText) + '' +' ' +' ' +' ' +' ' +' ' +' ' + productLabelText + ':' +' ' +' ' +' ' +' ' +' ' +'' + (orderItem.status === 'SKIPPED' ? '' : '' + skipOrderText + '') + '' +' ' var upcomingOrderOld = '' + ' ' + ' ' + ' ' + ' ' + ' ' + nextOrderDateLbl + ': ' + (new Date(orderItem.fulfillAt).toDateString()) + ' ' + statusLbl + ': ' + ' ' + (orderItem.status == "SKIPPED" ? skipBadgeText : queueBadgeText) + '' + ' ' + ' ' + skipOrderText + '' + ' ' + ' ' + ' ' + ' ' jQuery('#orderAcc_' + subItem.node?.id?.split('/')[4]).append(upcomingOrder); subItem.node.lines?.edges?.forEach(contractItem => { var upcomingOrderImage = ' ' var upcomingOrderProductTitle = '' + contractItem?.node?.title + (contractItem?.node?.variantTitle ? (' - ' + contractItem?.node?.variantTitle) : '') + (contractItem?.node?.quantity > 1 ? 'X' + contractItem?.node?.quantity + '' : '') + '' jQuery('#orderImage_' + orderItem.id.split("/").pop()).append(upcomingOrderImage); jQuery('#orderTitle_' + orderItem.id.split("/").pop()).append(upcomingOrderProductTitle); if (contractItem.node?.variantTitle == null) { jQuery('.appstle_variantTitle_' + contractItem.node?.productId.split('/')[4]).hide(); } }); }) } // Upcoming Order API CALL HERE if (subItem.node?.status == "ACTIVE" && !isPrepaidplan) { var upcomingOrderUrl; if (customerId != null) { upcomingOrderUrl = "https://subscription-admin.appstle.com/api/subscription-billing-attempts/top-orders?contractId=" + contractId + "&customerId=" + customerId + "&shop=" + shopName } else { upcomingOrderUrl = "https://subscription-admin.appstle.com/api/subscription-billing-attempts/top-orders?contractId=" + contractId + "&customerUid=" + token + "&shop=" + shopName } jQuery.ajax({ type: "GET", url: upcomingOrderUrl, dataType: "json", headers: { 'Access-Control-Allow-Origin': '*', }, success: function (result, status, xhr) { if (result?.length > 0) { result.map((orderItem) => { var upcomingOrder = '' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + nextOrderDateLbl + ': ' + (new Date(orderItem?.billingDate).toDateString()) + '' +' ' + (orderItem.status == "SKIPPED" ? skipBadgeText : queueBadgeText) + '' +' ' +' ' +' ' +' ' +' ' +' ' + productLabelText + ':' +' ' +' ' +' ' +' ' +' ' +'' + (orderItem.status === 'SKIPPED' ? '' : '' + skipOrderText + '') + '' +' ' var upcomingOrderOld = '' + ' ' + ' ' + ' ' + ' ' + ' ' + nextOrderDateLbl + ': ' + (new Date(orderItem.billingDate).toDateString()) + ' ' + statusLbl + ': ' + ' ' + (orderItem.status == "SKIPPED" ? skipBadgeText : queueBadgeText) + '' + ' ' + ' ' + skipOrderText + '' + ' ' + ' ' + ' ' + ' ' jQuery('#orderAcc_' + subItem.node?.id?.split('/')[4]).append(upcomingOrder); subItem.node.lines?.edges?.forEach(contractItem => { var upcomingOrderImage = ' ' var upcomingOrderProductTitle = '' + contractItem?.node?.title + (contractItem?.node?.variantTitle ? (' - ' + contractItem?.node?.variantTitle) : '') + (contractItem?.node?.quantity > 1 ? 'X' + contractItem?.node?.quantity + '' : '') + '' jQuery('#orderImage_' + orderItem.id).append(upcomingOrderImage); jQuery('#orderTitle_' + orderItem.id).append(upcomingOrderProductTitle); if (contractItem.node?.variantTitle == null) { jQuery('.appstle_variantTitle_' + contractItem.node?.productId.split('/')[4]).hide(); } }); }) } }, error: function (xhr, status, error) { console.log("Result: " + status + " " + error + " " + xhr.status + " " + xhr.statusText) } }) } } }); } else { var subscriptionList = ' ' +' ' +' ' +' ' +' ' + subscriptionNoText + ' - #' + subItem.node.id.split('/')[4] + '' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + subItem.node?.billingPolicy?.intervalCount + ' ' + frequencyIntervalTranslate + ' ' + subscriptionNoText + '' +' ' + (subItem.node.status == "ACTIVE" ? activeBadgeText : (subItem.node.status === "CANCELLED" ? closedBadgeText : (subItem.node.status === "PAUSED" ? pauseBadgeText : "")) )+ '' +' ' +'' + ((subItem.node.status === "CANCELLED" || subItem.node.status === "PAUSED") ? '' : ('' +' ' +' ' + nextOrderText + ': ' +' ' +' ' + (new Date(subItem.node?.nextBillingDate).toDateString()) + '' +' ' +' Processing.. Please Wait' +' ' +''+ ((changeNextOrderDateFlag == "true") ? ('' +' ' +' ') : '') + '' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + cancelChangeOrderBtnText + '' +' ' + updateChangeOrderBtnText + '' +' ' +' ' +' ')) + '' +'' + ((subItem.node.status === "CANCELLED") ? '' : ('' +' ' +' ' + orderFrequencyText + ': ' +' ' +' ' + subItem.node?.billingPolicy?.intervalCount + ' ' + frequencyIntervalTranslate + '' +' Processing.. Please Wait' +''+ ((subItem.node.status === "PAUSED") ? '' : ((changeOrderFrequencyFlag == "true") ? ('' +' ' +' ') : '')) + '' +' ' +' ' +' ' +' ' +' ' +' ' +' '+DayText+'' +' '+WeekText+'' +' '+MonthText+'' +' '+YearText+'' +' ' +' ' +' ' +' ' + cancelFreqBtnText + '' +' ' + updateFreqBtnText + '' +' ' +' ' +' ')) + '' +' ' +' ' +' ' + productLabelText + '' +' ' +' ' +' ' +''+ ((pauseResumeSubscriptionFlag === "true") ? ((subItem.node.status === "ACTIVE") ? ('' +' ' +' ' +' ' +' ' +' ' + pauseSubscriptionText + '' +' ') : '') : '') + '' +''+ ((pauseResumeSubscriptionFlag === "true") ? ((subItem.node.status === "PAUSED") ? ('' +' ' +' ' +' ' +' ' +' ' + resumeSubscriptionText + '' +' ') : '') : '') + '' +'' + ((subItem.node?.status === "CANCELLED" || subItem.node.status === "PAUSED") ? '' : ('' +' ' + seeMoreDetailsCta + '' +' ' + hideDetalsCta + '' +' ' +' ')) + '' +' ' +' ' +' ' + '' var addressDetails = extResult?.deliveryMethod?.address var accordionSection = ' ' +' ' +' ' +' ' + productAccordian + '' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + ShippingAccordianLabel + '' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + addressHeaderTitleText + '' +''+ ((changeShippingAddressFlag == "true") ? ('' +' ' +' ') : '') + '' +' ' +' ' +''+ ((addressDetails.firstName) ? ('' + addressDetails.firstName + '') : '') + ' ' + ((addressDetails.lastName) ? ('' + addressDetails.lastName + '') : '') + '' +''+ ((addressDetails.address1) ? ('' + addressDetails.address1 + '') : '') +''+ ((addressDetails.address2) ? ('' + addressDetails.address2 + '') : '') +''+ ((addressDetails.city) ? ('' + addressDetails.city + '') : '') +''+ ((addressDetails.province) ? (', ' + addressDetails.province + '') : '') +''+ ((addressDetails.country) ? (', ' + addressDetails.country + '') : '') +''+ ((addressDetails.zip) ? ('' + addressDetails.zip + '') : '') +''+ ((addressDetails.phone) ? ('' + addressDetails.phone + '') : '') +' ' +' ' +' ' +' ' +' ' +' ' + firstNameLabel + '' +' ' +' ' +' ' +' ' + lastNameLabel + '' +' ' +' ' +' ' +' ' + companyLabel + '' +' ' +' ' +' ' +' ' + phoneLabel + '' +' ' +' ' +' ' +' ' + address1Label + '' +' ' +' ' +' ' +' ' + address2Label + '' +' ' +' ' +' ' +' ' + cityLabel + '' +' ' +' ' +' ' +' ' + countryLabel + '' +' ' +' ' +' ' +' ' + provinceLabel + '' +' ' +' ' +' ' +' ' + zipLabel + '' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + cancelEditShippingBtnText + '' +' ' + updateEditShippingBtnText + '' +' ' +' ' +' ' +' ' +' ' + (isPrepaidplan ? upcomingFulfillmentAccordion : upcomingOrderAccordionTitle ) + ' ' + ' ' + ' ' + ' ' +' ' +' ' + paymentDetailAccordionTitle + '' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + paymentMethodTypeText + ': ' + paymentMethod + ' - ' + paymentData?.brand?.toUpperCase() + endingWithText + paymentData?.lastDigits + '' +' ' +' ' +' ' + cardHolderNameText + ': '+ paymentData?.name +'' +' ' +' ' +' ' + cardExpiryText + ': ' + paymentData?.expiryMonth + ' / ' + paymentData?.expiryYear + '' +' ' +' ' +' ' +' ' +' ' + updatePaymentBtnText + '' +' ' +' ' + paymentNotificationText + '' +' ' + '' + (!(shopName == "powerhouse-brewing-company.myshopify.com" && isPrepaidplan)? ('' + cancelAccordionTitle + ' ') : '') + '' + ' ' + ' ' + ' ' + ' ' + cancelSubscriptionBtnText + ' ' + ' ' + ' ' + ' ' +' ' jQuery('.appstle_myProduct').append(subscriptionList); jQuery('.appstle_myProduct').append(accordionSection); subItem.node.lines?.edges?.forEach((contractItem, idx) => { if (contractItem?.node?.productId != null) { var subscribedProduct = '' +' ' +' ' +' ' + contractItem.node.title + ' - ' + contractItem?.node?.variantTitle + '' +' ' +' ' +' ' + quantityLbl + ': ' + contractItem.node?.quantity + '' +' ' + amountLbl + ': ' + contractItem.node?.lineDiscountedPrice?.amount + ' ' + contractItem.node?.lineDiscountedPrice?.currencyCode + '' +' ' + nextOrderText + ': ' + (new Date(subItem.node?.nextBillingDate).toDateString()) + '' +' ' +' ' +' ' +' ' +' ' +' ' + editQuantityLabel + '' +' ' +' Please enter a valid number' +' ' +' ' +' Edit Variant' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + subTotalLabel + ': ' + contractItem.node?.lineDiscountedPrice?.amount + ' ' + contractItem.node?.lineDiscountedPrice?.currencyCode + '' +' ' + cancelButtonText + '' +' ' + updateButtonText + '' +' ' +' ' +' ' +''+ ((editProductFlag == "true") ? ('') : '') + '' +''+ ((deleteProductFlag == "true") ? ('') : '') +' ' +'' jQuery('#sub' + index).append(subscribedProduct) if (contractItem.node?.variantTitle == null) { jQuery('.appstle_variantTitle_' + contractItem.node?.productId?.split('/')[4]).hide(); } jQuery('.appstle_subscription_contract_product_list_wrapper_' + contractId).append( '' + contractItem.node?.title + (contractItem?.node?.variantTitle ? (' - ' + contractItem?.node?.variantTitle) : '') + (contractItem.node?.quantity > 1 ? 'x ' + contractItem.node?.quantity + '' : '') + '' ) let imageElement = jQuery(''); // imageElement.css('height', imageHeight); jQuery('.appstle_subscription_contract_image_wrapper_' + contractId).append(imageElement); } else { var subscribedProduct = '' + ' ' + ' ' + contractItem.node?.title + ' has been removed' + ' ' + '' jQuery('#sub' + index).append(subscribedProduct) } }); if(shopName != "taelor-style-dev.myshopify.com" && (addAdditionalProductFlag == "true")) jQuery('#sub' + index).prepend('' + addProductButtonText + '' + addProductLabelText + '' + addProductButtonText + '' + cancelButtonText + '') if(isPrepaidplan) { result?.originOrder?.fulfillmentOrders?.edges?.map((orderItem) => { var upcomingOrder = '' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + nextOrderDateLbl + ': ' + (new Date(orderItem?.fulfillAt).toDateString()) + '' +' ' + (orderItem.status == "SKIPPED" ? skipBadgeText : queueBadgeText) + '' +' ' +' ' +' ' +' ' +' ' +' ' + productLabelText + ':' +' ' +' ' +' ' +' ' +' ' +'' + (orderItem.status === 'SKIPPED' ? '' : '' + skipOrderText + '') + '' +' ' var upcomingOrderOld = '' + ' ' + ' ' + ' ' + ' ' + ' ' + nextOrderDateLbl + ': ' + (new Date(orderItem.fulfillAt).toDateString()) + ' ' + statusLbl + ': ' + ' ' + (orderItem.status == "SKIPPED" ? skipBadgeText : queueBadgeText) + '' + ' ' + ' ' + skipOrderText + '' + ' ' + ' ' + ' ' + ' ' jQuery('#orderAcc_' + subItem.node?.id?.split('/')[4]).append(upcomingOrder); subItem.node.lines?.edges?.forEach(contractItem => { var upcomingOrderImage = ' ' var upcomingOrderProductTitle = '' + contractItem?.node?.title + (contractItem?.node?.variantTitle ? (' - ' + contractItem?.node?.variantTitle) : '') + (contractItem?.node?.quantity > 1 ? 'X' + contractItem?.node?.quantity + '' : '') + '' jQuery('#orderImage_' + orderItem.id.split("/").pop()).append(upcomingOrderImage); jQuery('#orderTitle_' + orderItem.id.split("/").pop()).append(upcomingOrderProductTitle); if (contractItem.node?.variantTitle == null) { jQuery('.appstle_variantTitle_' + contractItem.node?.productId.split('/')[4]).hide(); } }); }) } // Upcoming Order API CALL HERE if (subItem.node?.status == "ACTIVE" && !isPrepaidplan) { var upcomingOrderUrl; if (customerId != null) { upcomingOrderUrl = "https://subscription-admin.appstle.com/api/subscription-billing-attempts/top-orders?contractId=" + contractId + "&customerId=" + customerId + "&shop=" + shopName } else { upcomingOrderUrl = "https://subscription-admin.appstle.com/api/subscription-billing-attempts/top-orders?contractId=" + contractId + "&customerUid=" + token + "&shop=" + shopName } jQuery.ajax({ type: "GET", url: upcomingOrderUrl, dataType: "json", headers: { 'Access-Control-Allow-Origin': '*', }, success: function (result, status, xhr) { if (result?.length > 0) { result.map((orderItem) => { var upcomingOrder = '' +' ' +' ' +' ' +' ' +' ' +' ' +' ' + nextOrderDateLbl + ': ' + (new Date(orderItem?.billingDate).toDateString()) + '' +' ' + (orderItem.status == "SKIPPED" ? skipBadgeText : queueBadgeText) + '' +' ' +' ' +' ' +' ' +' ' +' ' + productLabelText + ':' +' ' +' ' +' ' +' ' +' ' +'' + (orderItem.status === 'SKIPPED' ? '' : '' + skipOrderText + '') + '' +' ' var upcomingOrderOld = '' + ' ' + ' ' + ' ' + ' ' + ' ' + nextOrderDateLbl + ': ' + (new Date(orderItem?.billingDate).toDateString()) + ' ' + statusLbl + ': ' + ' ' + (orderItem.status == "SKIPPED" ? skipBadgeText : queueBadgeText) + '' + ' ' + ' ' + skipOrderText + '' + ' ' + ' ' + ' ' + ' ' jQuery('#orderAcc_' + subItem.node.id.split('/')[4]).append(upcomingOrder); subItem.node.lines?.edges?.forEach(contractItem => { if (contractItem.node?.productId != null) { var upcomingOrderImage = ' ' var upcomingOrderProductTitle = '' + contractItem?.node?.title + (contractItem?.node?.variantTitle ? (' - ' + contractItem?.node?.variantTitle) : '') + (contractItem?.node?.quantity > 1 ? 'X' + contractItem?.node?.quantity + '' : '') + '' jQuery('#orderImage_' + orderItem?.id).append(upcomingOrderImage); jQuery('#orderTitle_' + orderItem?.id).append(upcomingOrderProductTitle); if (contractItem.node.variantTitle == null) { jQuery('.appstle_variantTitle_' + contractItem.node?.productId?.split('/')[4]).hide(); } } else { var upcomingOrderImage = '' + ' ' + ' ' + contractItem.node?.title + ' has been removed' + ' ' + '' jQuery('#orderImage_' + orderItem.id).append(upcomingOrderImage) } }); }) } }, error: function (xhr, status, error) { console.log("Result: " + status + " " + error + " " + xhr.status + " " + xhr.statusText) } }) } } }, error: function (xhr, status, error) { console.log("Result: " + status + " " + error + " " + xhr.status + " " + xhr.statusText) } }); }); jQuery(".appstle_preloader").fadeOut(2000, function () { jQuery(".appstle_myProduct").fadeIn(1000); jQuery(".appstle_myProduct").css('visibility', 'visible'); if (getDeviceType() !== "mobile") { jQuery('.appstle_single_item_contract').each(function(index, el) { var contractId = jQuery(el).attr('data-contract-id'); var imageHeight = jQuery('.appstle_subscription_contract_content_wrapper_' + contractId).height(); jQuery('.appstle_subscription_contract_image_wrapper_' + contractId).parent().css('height', imageHeight);}) } }); } else { jQuery(".appstle_preloader").fadeOut(2000, function () { jQuery(".appstle_myProduct").append("" + noSubscriptionMessage + "").fadeIn(1000); jQuery(".appstle_myProduct").css('visibility', 'visible'); }); } attatchListener(); } function skipBillingOrder(id) { if (id != null && id != undefined) { jQuery('.appstle_skiporder_' + id).html('Processing...') jQuery.ajax({ type: "PUT", url: "https://subscription-admin.appstle.com/api/subscription-billing-attempts/skip-order/" + id + "?shop=" + Shopify.shop, dataType: "json", headers: { 'Access-Control-Allow-Origin': '*', }, success: function (result, status, xhr) { window.location.reload(); }, error: function (xhr, status, error) { console.log("Result: " + status + " " + error + " " + xhr.status + " " + xhr.statusText) } }); } else { alert("Order Id is not Found") } } function updatePaymentDetails(id) { if (id != null && id != undefined) { jQuery('.appstle_paymentBtnUpdate_' + id).html('Processing...'); jQuery.ajax({ type: "PUT", url: "https://subscription-admin.appstle.com/api/subscription-contracts-update-payment-method?contractId=" + id + "&shop=" + Shopify.shop, dataType: "json", headers: { 'Access-Control-Allow-Origin': '*', }, success: function (result, status, xhr) { jQuery(".appstle_paymentSuccessMessage_" + id).show(); jQuery('.appstle_paymentBtnUpdate_' + id).html(successText); setTimeout(function() {jQuery('.appstle_paymentBtnUpdate_' + id).html(updatePaymentBtnText);},5000) }, error: function (xhr, status, error) { console.log("Result: " + status + " " + error + " " + xhr.status + " " + xhr.statusText) jQuery(".appstle_paymentSuccessMessage_" + id).show(); jQuery('.appstle_paymentBtnUpdate_' + id).html(successText); setTimeout(function() {jQuery('.appstle_paymentBtnUpdate_' + id).html(updatePaymentBtnText);},5000) }, }); } else { alert("Contract Id is not Found") } } function cancelSubscription(id) { if (id != null && id != undefined) { jQuery('.appstle_cancelBtnText_' + id).html('Processing...') jQuery.ajax({ type: "DELETE", url: "https://subscription-admin.appstle.com/api/subscription-contracts/" + id + "?shop=" + Shopify.shop, dataType: "json", headers: { 'Access-Control-Allow-Origin': '*', }, success: function (result, status, xhr) { subscriptionInit(); }, error: function (xhr, status, error) { console.log("Result: " + status + " " + error + " " + xhr.status + " " + xhr.statusText) } }); } else { alert("Product Id is not Found") } } function showFrequencyForm(contractId) { // jQuery("#orderFrequencyform_" + contractId).show(); jQuery(".appstle_orderFrequencyformDiv_" + contractId).slideDown(); jQuery('.editBtnFrequency_' + contractId).hide(); } function showChangeOrderDateForm(contractId){ // jQuery("#orderDateform_" + contractId).show(); jQuery(".appstle_orderDateformDiv_" + contractId).slideDown(); jQuery('.editBtnOrderDate_' + contractId).hide(); } function hideOrderDateForm(contractId){ // jQuery("#orderDateform_" + contractId).hide(); jQuery(".appstle_orderDateformDiv_" + contractId).slideUp(); jQuery('.editBtnOrderDate_' + contractId).show(); } function hideFrequencyForm(contractId) { jQuery(".appstle_orderFrequencyformDiv_" + contractId).slideUp(); // jQuery("#orderFrequencyform_" + contractId).hide(); jQuery('.editBtnFrequency_' + contractId).show(); } function updateOrderDate(contractId) { var nextBillingDate = document.forms["orderDateform_" + contractId].changeOrderDate.value; if (nextBillingDate != null && nextBillingDate != undefined) { // jQuery("#orderDateform_" + contractId).hide(); jQuery(".appstle_orderDateformDiv_" + contractId).slideUp(); jQuery("#orderDateloadingText_" + contractId).show(); jQuery.ajax({ type: "PUT", url: "https://subscription-admin.appstle.com/api/subscription-contracts-update-billing-date?contractId=" + contractId + "&nextBillingDate=" + new Date(nextBillingDate).toISOString() + "&shop=" + Shopify.shop, dataType: "json", headers: { 'Access-Control-Allow-Origin': '*', }, success: function (result, status, xhr) { subscriptionInit() }, error: function (xhr, status, error) { console.log("Result: " + status + " " + error + " " + xhr.status + " " + xhr.statusText) } }); // jQuery("#orderloadingText_"+contractId).hide(); } else { alert("Please Provide Frequency Count or Frequency Interval") } } function updateFrequency(contractId) { var frequencyCount = document.forms["orderFrequencyform_" + contractId]?.frequencyCount?.value; var frequencyInterval = document.forms["orderFrequencyform_" + contractId]?.frequencyInterval?.value; if (frequencyCount = 0 && frequencyInterval != null && frequencyInterval != undefined) { // jQuery("#orderFrequencyform_" + contractId).hide(); jQuery(".appstle_orderFrequencyformDiv_" + contractId).slideUp(); jQuery("#orderloadingText_" + contractId).show(); jQuery.ajax({ type: "PUT", url: "https://subscription-admin.appstle.com/api/subscription-contracts-update-billing-interval?contractId=" + contractId + "&interval=" + frequencyInterval + "&intervalCount=" + frequencyCount + "&shop=" + Shopify.shop, dataType: "json", headers: { 'Access-Control-Allow-Origin': '*', }, success: function (result, status, xhr) { subscriptionInit(); }, error: function (xhr, status, error) { console.log("Result: " + status + " " + error + " " + xhr.status + " " + xhr.statusText) } }); // jQuery("#orderloadingText_"+contractId).hide(); } else { alert("Please Provide Frequency Count or Frequency Interval") } } function attatchListener() { jQuery('.appstle_product-search-button').on('click', function() { var contractId = jQuery(this).attr('data-contract-id'); var selectedProduct = jQuery('select[data-contract-id=' + contractId + ']'); if (!selectedProduct.val()) { alert('Please Select a product to add.') return; } jQuery(".appstle_myProduct").fadeOut(500, function () { jQuery(".appstle_preloader").fadeIn(250); }); var addLine_settings = { "async": true, "crossDomain": true, "url": 'https://subscription-admin.appstle.com/api/subscription-contracts-add-line-item?contractId=' + contractId + '&price=' + selectedProduct.attr('data-variant-price') + '&quantity=1&shop=' + shopName + '&variantId=' + selectedProduct.attr('data-variant-id'), "method": "PUT", "headers": { "cache-control": "no-cache", } } jQuery.ajax(addLine_settings).done(function (response) { subscriptionInit(); }) }) jQuery('.appstle_select_wrapper select').on('change', function() { var currentValue= jQuery(this).val(); var selectedVariantPrice = jQuery(this).find('option[value="' + currentValue + '"]').attr('data-variant-price'); var formid = jQuery(this).attr('data-edit'); jQuery('#' + formid).attr('data-price', selectedVariantPrice); }) jQuery('.appstle_editButton').on('click', function() { var formid = jQuery(this).attr('data-edit'); jQuery('#' + formid).find('.appstle_edit_wrapper').slideDown(); jQuery('#' + formid).find('.appstle_editDeleteGroup').hide(); jQuery('#' + formid).find('.appstle_buttonGroup').show(); }) jQuery('.appstle_cancelButton').on('click', function() { var formid = jQuery(this).attr('data-edit'); jQuery('#' + formid).find('.appstle_edit_wrapper').slideUp(); jQuery('#' + formid).find('.appstle_editDeleteGroup').show(); jQuery('#' + formid).find('.appstle_buttonGroup').hide(); }) jQuery('.appstle_deleteButton').on('click', function() { var formid = jQuery(this).attr('data-edit'); var lineId = jQuery('#' + formid).attr('data-line-id'); let prepaidPlanFlag = jQuery('#' + formid).attr('data-isPrepaid'); var contractId = jQuery('#' + formid).attr('data-contract-id'); var shop = jQuery('#' + formid).attr('data-shop'); deletePopupConfirm(prepaidPlanFlag); // Showing Delete confirm Model // On click of confirm Code will execute jQuery('.appstle_delete_model_yesbtn').on('click', function() { hideDeleteConfirmPopup(); // Hide the Confirm Model jQuery(".appstle_myProduct").fadeOut(500, function () { jQuery(".appstle_preloader").fadeIn(250); }); var settings = { "async": true, "crossDomain": true, "url": 'https://subscription-admin.appstle.com/api/subscription-contracts-remove-line-item?contractId=' + contractId + '&lineId=' + lineId + '&shop=' + shop, "method": "PUT", "headers": { "cache-control": "no-cache", "postman-token": "06eaf057-9152-2ff9-616b-c8f3f319e47f" } } jQuery.ajax(settings).done(function (response) { subscriptionInit(); }); }) }) jQuery('.appstle_updateButton').on('click', function() { var formid = jQuery(this).attr('data-edit'); var lineId = jQuery('#' + formid).attr('data-line-id'); var contractId = jQuery('#' + formid).attr('data-contract-id'); var shop = jQuery('#' + formid).attr('data-shop'); var price = jQuery('#' + formid).attr('data-price'); var formData = jQuery('#' + formid + ' form').serialize(); var inputElementValue = jQuery('#' + formid).find('input')[0].value; if (validateNumber(inputElementValue)) { jQuery(".appstle_myProduct").fadeOut(500, function () { jQuery(".appstle_preloader").fadeIn(250); }); jQuery('#' + formid).find('.appstle_input_error').hide(); var settings = { "async": true, "crossDomain": true, "url": 'https://subscription-admin.appstle.com/api/subscription-contracts-update-line-item?contractId=' + contractId + '&price=' + price + '&lineId=' + lineId + '&shop=' + shop + '&' + formData, "method": "PUT", "headers": { "cache-control": "no-cache", "postman-token": "06eaf057-9152-2ff9-616b-c8f3f319e47f" } } jQuery.ajax(settings).done(function (response) { subscriptionInit(); }); } else { jQuery('#' + formid).find('.appstle_input_error').show(); } }); addVariant(); addSelect2InHead(); addIconCssInHead(); } function addVariant() { var elementsWithProductId = Array.prototype.slice.call(jQuery('[data-product-id]')) const addVariantItem = async () => { if (elementsWithProductId.length > 0) { var item = elementsWithProductId.shift(); var settings = { "async": true, "crossDomain": true, "url": 'https://subscription-admin.appstle.com/api/data/product?productId=' + jQuery(item).attr('data-product-id') + '&shop=' + shopName, "method": "GET", "headers": { "cache-control": "no-cache", "postman-token": "06eaf057-9152-2ff9-616b-c8f3f319e47f" } } jQuery.ajax(settings).done(function (response) { var variants = response?.variants; jQuery(variants).each(function (index, variant) { var option = jQuery('', { value: variant.admin_graphql_api_id, text: variant.title, selected: ((variant?.admin_graphql_api_id == jQuery(item).attr("data-variant-id")) ? true : false), }) option.attr('data-variant-price', variant.price); option.appendTo(jQuery(item).find('select')); }); if (variants.length 0) { var item = selectedItems.shift(); var settings = { "async": true, "crossDomain": true, "url": 'https://subscription-admin.appstle.com/api/data/product?productId=' + item + '&shop=' + shopName, "method": "GET", "headers": { "cache-control": "no-cache", } } jQuery.ajax(settings).done(function (response) { var firstVariant = response?.variants[0] var addLine_settings = { "async": true, "crossDomain": true, "url": 'https://subscription-admin.appstle.com/api/subscription-contracts-add-line-item?contractId=' + contractId + '&price=' + firstVariant?.price + '&quantity=1&shop=' + shopName + '&variantId=' + firstVariant?.admin_graphql_api_id, "method": "PUT", "headers": { "cache-control": "no-cache", } } jQuery.ajax(addLine_settings).done(function (response) { addline(); }) }); } else { subscriptionInit(); } } addline(); } function validateNumber(value) { var type = typeof value; if (type === 'undefined') { return true; } else if (!value.trim()) { return false; } else if (isNaN(value)) { return false; } else if (parseInt(value) < 1) { return false; } else { return true; } }; function addSelect2InHead() { jQuery('head').append('') checkSelect2Initialised() } function addIconCssInHead() { jQuery('head').append('') } function checkSelect2Initialised() { try { initiateSelect2() } catch(err) { setTimeout(checkSelect2Initialised,2000) } } function initiateSelect2() { jQuery(".appstle_product-search-select").each(function(index, selectEl) { jQuery(selectEl).on('select2:select', function (e) { var data = e.params.data; var selecTargetEl = jQuery(e.target) selecTargetEl.attr('data-variant-price', data.price); selecTargetEl.attr('data-variant-id', data.id); }); var lastSearchTerm = ""; var next = false; var cursor = null; jQuery(selectEl).select2({ ajax: { url: "https://subscription-admin.appstle.com/api/data/v2/product-variants", dataType: 'json', delay: 250, data: function (params) { if (params.term !== lastSearchTerm) { next = false; cursor = null; } lastSearchTerm = params.term; return { search: params.term, // search term cursor: cursor, next: next, shop: shopName }; }, "async": true, "crossDomain": true, "headers": { "cache-control": "no-cache", "postman-token": "06eaf057-9152-2ff9-616b-c8f3f319e47f" }, processResults: function (data, params) { next = data.products.pageInfo.hasNextPage; cursor = data.products.edges[data.products.edges.length - 1].cursor; // Remove draft products var listData = data.products.edges.filter(function(line) { return line?.node?.status === 'ACTIVE' }) // Append variants to list var resultsData = [] listData = listData.forEach(function(line) { if (line?.node?.totalVariants === 1) { var item = {} item.title = line?.node?.title; item.price = line?.node?.variants?.edges[0]?.node?.price; item.id = line?.node?.variants?.edges[0]?.node?.id; item.imgSrc = line?.node?.featuredImage?.transformedSrc; item.currencyCode = line?.node?.priceRangeV2?.maxVariantPrice?.currencyCode; resultsData = [...resultsData, item]; } else { line?.node?.variants?.edges.forEach(function(variantLine) { var item = {} item.title = variantLine?.node?.displayName; item.price = variantLine?.node?.price; item.id = variantLine?.node?.id; item.imgSrc = line?.node?.featuredImage?.transformedSrc; item.currencyCode = line?.node?.priceRangeV2?.maxVariantPrice?.currencyCode; resultsData = [...resultsData, item]; }) } }) // listData = listData.map(function(line) { // }) // listData = listData.map(function(line) { // return { // id: line?.node?.id, // title: line?.node?.title, // imgSrc: line?.node?.featuredImage?.transformedSrc // } // }) return { results: resultsData, pagination: { more: data.products.pageInfo.hasNextPage } }; }, cache: true }, minimumInputLength: 0, templateResult: formatRepo, templateSelection: formatRepoSelection }); }) } function contractDetailsFromContractId(contractId) { jQuery.ajax({ type: "GET", url: 'https://subscription-admin.appstle.com/api/subscription-contracts/contract-external/' + contractId + '?shop=' +shopName, dataType: "json", headers: { 'Access-Control-Allow-Origin': '*', }, success: function (result, status, xhr) { return result console.log("My Contrcat Data" + result); }, error: function (xhr, status, error) { console.log("Result: " + status + " " + error + " " + xhr.status + " " + xhr.statusText) } }); } function formatRepo (product) { var container = jQuery( "" + "" + "" + "" + product?.title + "" + "" + product?.price + " " + product?.currencyCode + "" + "" + "" ); return container; } function formatRepoSelection (product) { return product.title; } function addStyle() { var css = _RSConfig?.css; jQuery('' + css?.customerPortalCss + '').appendTo(jQuery('head')); } function shopifyLoaded() { if (window.hasOwnProperty('Shopify')) { window.shopName = Shopify.shop; window.customerId = __st.cid; if (customerId == null) { customerId = urlParams.get('customerId'); } subscriptionInit(); addStyle(); } else { setTimeout(shopifyLoaded, 2000) } } function toggleChangeAddressForm(contractId) { jQuery('.appstle_ShippingAcc_' + contractId).find('.editBtnAddress_' + contractId).toggle(); jQuery('.appstle_ShippingAcc_' + contractId).find('.appstle_address_viewOnly').slideToggle(); jQuery('.appstle_ShippingAcc_' + contractId).find('.appstle_address_editForm').slideToggle(); } function updateShippingAddress(contractId) { jQuery('.appstle_ShippingAcc_' + contractId).find('.appstle_edit_shipping_update-button span').hide(); jQuery('.appstle_ShippingAcc_' + contractId).find('.appstle_edit_shipping_update-button .appstle_loaderTiny').show(); var formdata = jQuery('.appstle_ShippingAcc_' + contractId).find('form').serializeArray(); var data = {}; jQuery(formdata).each(function(index, obj){ data[obj.name] = obj.value; }); data['name'] = data['firstName'] + ' ' + data['lastName']; var settings = { "url": "https://subscription-admin.appstle.com/api/subscription-contracts-update-shipping-address?contractId=" + contractId + "&shop=" + shopName, "method": "PUT", "timeout": 0, "headers": { "Content-Type": "application/json" }, "data": JSON.stringify(data), }; jQuery.ajax(settings).done(function (response) { jQuery(".appstle_myProduct").fadeOut(500, function () { jQuery(".appstle_preloader").fadeIn(250); subscriptionInit(); }); }); } function pauseSubscription(contractId) { jQuery('.appstle_subscription_contract_content_wrapper_' + contractId).find('.appstle_pause_subscription_button .appstle_icon_wrapper').hide(); jQuery('.appstle_subscription_contract_content_wrapper_' + contractId).find('.appstle_pause_subscription_button .appstle_loaderTiny').show(); var settings = { "url": "https://subscription-admin.appstle.com/api/subscription-contracts-update-status?contractId=" + contractId + "&status=PAUSED&shop=" + shopName, "method": "PUT", "timeout": 0, }; jQuery.ajax(settings).done(function (response) { jQuery(".appstle_myProduct").fadeOut(500, function () { jQuery(".appstle_preloader").fadeIn(250); subscriptionInit(); }); }); } function resumeSubscription(contractId) { jQuery('.appstle_subscription_contract_content_wrapper_' + contractId).find('.appstle_resume_subscription_button .appstle_icon_wrapper').hide(); jQuery('.appstle_subscription_contract_content_wrapper_' + contractId).find('.appstle_resume_subscription_button .appstle_loaderTiny').show(); var settings = { "url": "https://subscription-admin.appstle.com/api/subscription-contracts-update-status?contractId=" + contractId + "&status=ACTIVE&shop=" + shopName, "method": "PUT", "timeout": 0, }; jQuery.ajax(settings).done(function (response) { jQuery(".appstle_myProduct").fadeOut(500, function () { jQuery(".appstle_preloader").fadeIn(250); subscriptionInit(); }); }); } jQuery(document).ready(function () { shopifyLoaded(); }); // ]]>