subscription

append(`
×
Are you sure you want to delete ?
`) } 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 windows. onclick = function(event) { if (event. target == appstleDeletePopupModal) { hideDelete ConfirmPopup() } } } function hide Delete ConfirmPopup () { 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 { windows. location. href = 'https://'+ shopName +'/account' } } function accordionToggle(ev) { // var acc = document. getElementsByClassName("accordion"); // var i; maybe classList. toggle("active"); var panel = possibly nextElementSibling; $(panel). slideToggle() } function toggleContractAccordian(el) { var selector = $(el). attr('data-accordian-selector') $(el). toggleClass("active"); $(selectors). slideToggle() } function getDeviceType() { const ua = navigator. userAgent; if (/(tablet|ipad|playbook|silk)|(android(?!. *mobile))/i. test(ua)) { return "tablet"; } if ( /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/. test( etc ) ) { 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'). value(); if(parseInt(qty) <= 0) { jQuery('#' + selector). find(' appstle_input_error'). show(); return; } else jQuery('#' + selector). find(' appstle_input_error'). hide(); var selectedVariantPrice = variantSelectField. find('option[value="' + variantSelectField. val() + '"]'). attr('data-variant-price'); productEl. find(' appstle_edit_total span'). text(parseFloat(selectedVariantPrice) * parseInt(qty) + ' ' + currencyCode); } function hideAddProductsSearchBar(el) { var currentElement = jQuery(el); currentElement. parent(). parent(). hide() currentElement. parent(). parent(). prev(). show() } function showAddProductsSearchBar(el) { var currentElement = jQuery(el); currentElement. hide(); currentElement. next(). show(); } function subscriptionRender(subscriptionUrl, validContractIdUrl, shopName, customerId, token) { jQuery. ajax({ async: "true", type: "GET", url: subscriptionUrl, dataType: "json", headers: { 'Access-Control-Allow-Origin': '*', }, success: function (result, status, xhr) { jQuery. ajax({ async: "true", type: "GET", url: validContractIdUrl, dataType: "json", headers: { 'Access-Control-Allow-Origin': '*', }, success: function (validContractId, status, xhr) { renderPage(result, validContractId); }, error: function (xhr, status, error) { console. log("Result: " + status + " " + error + " " + xhr. status + " " + xhr. status text) } }); }, error: function (xhr, status, error) { console. log("Result: " + status + " " + error + " " + xhr. status + " " + xhr. status text) } }); } function renderPage(result, validContractId) { if (result?. subscription contracts? edge?. length > 0) { var subscription Contract Data = result. subscription contracts edge sort(function (a, b) { if (a. node. status b. node. state) { 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?. intervals; 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?. interval count) { isPrepaidplan = false; } if (subItem. node. lines?. edge?. length == 1) { subitem. node. lines?. edge?. forEach(contractItem => { if (contractItem?. node?. productId == null) { var accordionSection = '
' + '
' + '
' + '

' + subscriptionNoText + ' - #' + subItem. node. i.e split('/')[4] + '

' + '
' + '

' + '
' + contractItem. node. title + ' has been removed.
' + ' ' + '
' + '
' + '
' + ' ' + '
' + '
' + '
' + '
' jQuery('. appstle_myProduct'). append(accordionSection); } else { var subscriptionList = '
' +'
' +'
' +'
' +'

' + subscriptionNoText + ' - #' + subItem. node. i.e 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. next billing date). toDateString()) + '' +' ' +''+ ((changeNextOrderDateFlag == "true") ? ('') : '') + '' +'
' +'
' +' ' +'
')) + '' +'' + ((subItem. node. status === "CANCELLED") ? '' : ('
' +'
' +' ' + orderFrequencyText + ': ' +'
' +' ' + subItem. node. billingPolicy intervalCount + ' ' + frequencyIntervalTranslate + '' +' ' +''+ ((subItem. node. status === "PAUSED") ? '' : ((changeOrderFrequencyFlag == "true") ? ('') : '')) + '' +'
' +'
' +' ' +'
')) + '' +'
' +'
' +' ' + productLabelText + '' +'
' +'
' +'
' +''+ ((pauseResumeSubscriptionFlag === "true") ? ((subItem. node. status === "ACTIVE") ? ('') : '') : '') + '' +''+ ((pauseResumeSubscriptionFlag === "true") ? ((subItem. node. status === "PAUSED") ? ('') : '') : '') + '' +'' + ((subItem. node. status === "CANCELLED" || subitem. node. status === "PAUSED") ? '' : ('
' +' ' + seeMoreDetailsCta + '' +' ' +' ' +'
')) + '' +'
' +'
' +'
' + '
' var addressDetails = extResult?. deliveryMethod?. address var accordionSection = ' ' jQuery('. appstle_myProduct'). append(subscriptionList); jQuery('. appstle_myProduct'). append(accordionSection); subitem. node. lines?. edge?. 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?. next billing date). toDateString()) + '
' +'
' +'
' +' ' +' ' +'
' +'
' +''+ ((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?. amount > 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('
') if(isPrepaidplan) { result?. originOrder?. fulfillmentOrders?. edge?. map((orderItem) => { var upcomingOrder = '
' +'
' +'
' +'
' +'
' +'
' +'
' +' ' + nextOrderDateLbl + ': ' + (new Date(orderItem?. fulfillAt). toDateString()) + '' +' ' + (orderItem. status == "SKIPPED" ? skipBadgeText : queueBadgeText) + '' +'
' +'
' +'
' +'
' +'
' +' ' + productLabelText + ':' +'
' +'
' +'
' +'
' +'
' +'' + (orderItem. status === 'SKIPPED' ? '' : '') + '' +'
' var upcomingOrderOld = '
' + '
' + '
' + '
' + '
' + '
' + nextOrderDateLbl + ': ' + (new Date(orderItem. fulfillAt). toDateString()) + '
' + statusLbl + ': ' + ' ' + (orderItem. status == "SKIPPED" ? skipBadgeText : queueBadgeText) + '' + '

' + ' ' + '

' + '
' + '
' + '
' jQuery('#orderAcc_' + subItem. node?. id? split('/')[4]). append(upcomingOrder); subitem. node. lines?. edge?. forEach(contractItem => { var upcomingOrderImage = '
' var upcomingOrderProductTitle = '
' + contractItem?. node?. title + (contractItem?. node?. variantTitle ? (' - ' + contractItem?. node?. variantTitle) : '') + (contractItem?. node?. amount > 1 ? 'X' + contractItem?. node?. quantity + '' : '') + '
' jQuery('#orderImage_' + orderItem. i.e split("/"). pop()). append(upcomingOrderImage); jQuery('#orderTitle_' + orderItem. i.e 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?. billing date). toDateString()) + '' +' ' + (orderItem. status == "SKIPPED" ? skipBadgeText : queueBadgeText) + '' +'
' +'
' +'
' +'
' +'
' +' ' + productLabelText + ':' +'
' +'
' +'
' +'
' +'
' +'' + (orderItem. status === 'SKIPPED' ? '' : '') + '' +'
' var upcomingOrderOld = '
' + '
' + '
' + '
' + '
' + '
' + nextOrderDateLbl + ': ' + (new Date(orderItem. billing date). toDateString()) + '
' + statusLbl + ': ' + ' ' + (orderItem. status == "SKIPPED" ? skipBadgeText : queueBadgeText) + '' + '

' + ' ' + '

' + '
' + '
' + '
' jQuery('#orderAcc_' + subItem. node?. id? split('/')[4]). append(upcomingOrder); subitem. node. lines?. edge?. forEach(contractItem => { var upcomingOrderImage = '
' var upcomingOrderProductTitle = '
' + contractItem?. node?. title + (contractItem?. node?. variantTitle ? (' - ' + contractItem?. node?. variantTitle) : '') + (contractItem?. node?. amount > 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. status text) } }) } } }); } else { var subscriptionList = '
' +'
' +'
' +'
' +'

' + subscriptionNoText + ' - #' + subItem. node. i.e 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?. next billing date). toDateString()) + '' +' ' +''+ ((changeNextOrderDateFlag == "true") ? ('') : '') + '' +'
' +'
' +' ' +'
')) + '' +'' + ((subItem. node. status === "CANCELLED") ? '' : ('
' +'
' +' ' + orderFrequencyText + ': ' +'
' +' ' + subItem. node?. billingPolicy?. intervalCount + ' ' + frequencyIntervalTranslate + '' +' ' +''+ ((subItem. node. status === "PAUSED") ? '' : ((changeOrderFrequencyFlag == "true") ? ('') : '')) + '' +'
' +'
' +' ' +'
')) + '' +'
' +'
' +' ' + productLabelText + '' +'
' +'
' +'
' +''+ ((pauseResumeSubscriptionFlag === "true") ? ((subItem. node. status === "ACTIVE") ? ('') : '') : '') + '' +''+ ((pauseResumeSubscriptionFlag === "true") ? ((subItem. node. status === "PAUSED") ? ('') : '') : '') + '' +'' + ((subItem. node?. status === "CANCELLED" || subitem. node. status === "PAUSED") ? '' : ('
' +' ' + seeMoreDetailsCta + '' +' ' +' ' +'
')) + '' +'
' +'
' +'
' + '
' var addressDetails = extResult?. deliveryMethod?. address var accordionSection = ' ' jQuery('. appstle_myProduct'). append(subscriptionList); jQuery('. appstle_myProduct'). append(accordionSection); subitem. node. lines?. edge?. 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?. next billing date). toDateString()) + '
' +'
' +'
' +' ' +' ' +'
' +'
' +''+ ((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?. amount > 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('
') if(isPrepaidplan) { result?. originOrder?. fulfillmentOrders?. edge?. map((orderItem) => { var upcomingOrder = '
' +'
' +'
' +'
' +'
' +'
' +'
' +' ' + nextOrderDateLbl + ': ' + (new Date(orderItem?. fulfillAt). toDateString()) + '' +' ' + (orderItem. status == "SKIPPED" ? skipBadgeText : queueBadgeText) + '' +'
' +'
' +'
' +'
' +'
' +' ' + productLabelText + ':' +'
' +'
' +'
' +'
' +'
' +'' + (orderItem. status === 'SKIPPED' ? '' : '') + '' +'
' var upcomingOrderOld = '
' + '
' + '
' + '
' + '
' + '
' + nextOrderDateLbl + ': ' + (new Date(orderItem. fulfillAt). toDateString()) + '
' + statusLbl + ': ' + ' ' + (orderItem. status == "SKIPPED" ? skipBadgeText : queueBadgeText) + '' + '

' + ' ' + '

' + '
' + '
' + '
' jQuery('#orderAcc_' + subItem. node?. id? split('/')[4]). append(upcomingOrder); subitem. node. lines?. edge?. forEach(contractItem => { var upcomingOrderImage = '
' var upcomingOrderProductTitle = '
' + contractItem?. node?. title + (contractItem?. node?. variantTitle ? (' - ' + contractItem?. node?. variantTitle) : '') + (contractItem?. node?. amount > 1 ? 'X' + contractItem?. node?. quantity + '' : '') + '
' jQuery('#orderImage_' + orderItem. i.e split("/"). pop()). append(upcomingOrderImage); jQuery('#orderTitle_' + orderItem. i.e 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?. billing date). toDateString()) + '' +' ' + (orderItem. status == "SKIPPED" ? skipBadgeText : queueBadgeText) + '' +'
' +'
' +'
' +'
' +'
' +' ' + productLabelText + ':' +'
' +'
' +'
' +'
' +'
' +'' + (orderItem. status === 'SKIPPED' ? '' : '') + '' +'
' var upcomingOrderOld = '
' + '
' + '
' + '
' + '
' + '
' + nextOrderDateLbl + ': ' + (new Date(orderItem?. billing date). toDateString()) + '
' + statusLbl + ': ' + ' ' + (orderItem. status == "SKIPPED" ? skipBadgeText : queueBadgeText) + '' + '

' + ' ' + '

' + '
' + '
' + '
' jQuery('#orderAcc_' + subItem. node. i.e split('/')[4]). append(upcomingOrder); subitem. node. lines?. edge?. forEach(contractItem => { if (contractItem. node?. productId != null) { var upcomingOrderImage = '
' var upcomingOrderProductTitle = '
' + contractItem?. node?. title + (contractItem?. node?. variantTitle ? (' - ' + contractItem?. node?. variantTitle) : '') + (contractItem?. node?. amount > 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. status text) } }) } } }, error: function (xhr, status, error) { console. log("Result: " + status + " " + error + " " + xhr. status + " " + xhr. status text) } }); }); 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("

" + no Subscription Message + "

"). fadeIn(1000); jQuery(". appstle_myProduct"). css('visibility', 'visible'); }); } attachListener(); } function skipBillingOrder(id) { if (id != null && id != undefined) { jQuery('. appstle_skiorder_' + 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) { windows. location. reload(); }, error: function (xhr, status, error) { console. log("Result: " + status + " " + error + " " + xhr. status + " " + xhr. status text) } }); } 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. status text) 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. status text) } }); } 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. status text) } }); // 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]?. Frequency Interval?. value; if (frequencyCount <= 0) alert("Frequency Count must be greater than 1") if (frequencyCount != null && frequencyCount != undefined && 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. status text) } }); // jQuery("#orderloadingText_"+contractId). hide(); } else { alert("Please Provide Frequency Count or Frequency Interval") } } function attachListener() { 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). value(); 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'); delete PopupConfirm(prepaidPlanFlag); // Showing Delete confirm Modal // On click of confirm Code will execute jQuery('. appstle_delete_model_yesbtn'). on('click', function() { hide Delete Confirm Popup(); // Hide the Confirm Modal 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('

Deine eCard - personalisieren, downloaden & teilen!