<!-- 💙 MEMBERSCRIPT #187 v0.1 💙 - SHOW MEMBER CURRENT PLAN BUTTON -->
<script>
(function() {
'use strict';
document.addEventListener("DOMContentLoaded", async function() {
try {
// Check if Memberstack is loaded
if (!window.$memberstackDom) {
console.error('MemberScript #187: Memberstack DOM package is not loaded.');
return;
}
const memberstack = window.$memberstackDom;
// Wait for Memberstack to be ready
await waitForMemberstack();
// Get current member
const { data: member } = await memberstack.getCurrentMember();
// If no member is logged in, do nothing
if (!member) {
return;
}
// Get the current plan connection
let planConnections = null;
if (member.planConnections) {
planConnections = member.planConnections;
} else if (member.data && member.data.planConnections) {
planConnections = member.data.planConnections;
} else if (member.plans) {
planConnections = member.plans;
}
// If no plan connections, do nothing
if (!planConnections || planConnections.length === 0) {
return;
}
// Get the current plan connection details
const planConnection = planConnections[0];
const currentPlanId = planConnection?.planId;
// Get the price ID from the payment object
const currentPriceId = planConnection?.payment?.priceId;
if (!currentPlanId) {
return;
}
// Find all buttons with Memberstack plan attributes
// Look for data-ms-price:update, data-ms-price:add, data-ms-plan:update, or data-ms-plan:add attributes
const buttons = document.querySelectorAll(
'[data-ms-price\\:update], [data-ms-price\\:add], [data-ms-plan\\:update], [data-ms-plan\\:add]'
);
// Update matching button to say "Current Plan"
buttons.forEach(button => {
// Get the plan ID from data-ms-price:update, data-ms-price:add, data-ms-plan:update, or data-ms-plan:add
const planIdFromPriceUpdate = button.getAttribute('data-ms-price:update');
const planIdFromPriceAdd = button.getAttribute('data-ms-price:add');
const planIdFromPlanUpdate = button.getAttribute('data-ms-plan:update');
const planIdFromPlanAdd = button.getAttribute('data-ms-plan:add');
const buttonPlanId = planIdFromPriceUpdate || planIdFromPriceAdd || planIdFromPlanUpdate || planIdFromPlanAdd;
// Check if this button's price ID matches the current price ID
// OR if it matches the plan ID (covering both scenarios)
if (buttonPlanId === currentPriceId || buttonPlanId === currentPlanId) {
// Update button text
button.textContent = 'Current Plan';
// Disable the button to prevent clicking
if (button.disabled !== undefined) {
button.disabled = true;
}
// Add a class for styling (optional)
button.classList.add('current-plan-button');
// Update href to prevent navigation
if (button.tagName.toLowerCase() === 'a') {
button.setAttribute('href', 'javascript:void(0)');
button.style.cursor = 'not-allowed';
button.style.opacity = '0.6';
button.setAttribute('onclick', 'return false;');
}
// Add style attributes for immediate visual feedback
button.style.pointerEvents = 'none';
}
});
} catch (error) {
console.error('MemberScript #187: Error updating button:', error);
}
});
function waitForMemberstack() {
return new Promise((resolve) => {
if (window.$memberstackDom && window.$memberstackReady) {
resolve();
} else {
document.addEventListener('memberstack.ready', resolve);
// Fallback timeout
setTimeout(resolve, 2000);
}
});
}
})();
</script>
Customer Showcase
Have you used a Memberscript in your project? We’d love to highlight your work and share it with the community!
2. Navegue hasta Make.com y Cree un nuevo escenario...
3. Haga clic en el pequeño cuadro con 3 puntos y luego Importar Blueprint...
4. Sube tu archivo y ¡voilá! Ya está listo para vincular sus propias cuentas.
¿Necesitas ayuda con este MemberScript?
Todos los clientes de Memberstack pueden solicitar asistencia en el Slack 2.0. Tenga en cuenta que no se trata de funciones oficiales y que no se puede garantizar la asistencia.
"Hemos estado utilizando Memberstack durante mucho tiempo, y nos ha ayudado a lograr cosas que nunca hubiéramos creído posible usando Webflow. Nos ha permitido construir plataformas con gran profundidad y funcionalidad y el equipo que hay detrás siempre ha sido súper servicial y receptivo a los comentarios"
Jamie Debnam
39 Digital
"He estado construyendo un sitio de membresía con Memberstack y Jetboost para un cliente. Se siente como magia construir con estas herramientas. Como alguien que ha trabajado en una agencia donde algunas de estas aplicaciones fueron codificadas desde cero, finalmente entiendo el bombo ahora. Esto es mucho más rápido y mucho más barato."
Félix Meens
Estudio Webflix
"Uno de los mejores productos para iniciar un sitio de membresía - Me gusta la facilidad de uso de Memberstack. Yo era capaz de mi sitio de membresía en marcha y funcionando dentro de un día. No hay nada más fácil que eso. También proporciona la funcionalidad que necesito para hacer la experiencia del usuario más personalizada."
Eric McQuesten
Nerds de la tecnología sanitaria
Depósito Off World
"Mi negocio no sería lo que es sin Memberstack. Si crees que 30 $/mes es caro, prueba a contratar a un desarrollador para que integre recomendaciones personalizadas en tu sitio por ese precio. Increíblemente flexible conjunto de herramientas para aquellos dispuestos a poner en algunos esfuerzos mínimos para ver su documentación bien elaborado."
Riley Brown
Depósito Off World
"La comunidad de Slack es una de las más activas que he visto y los clientes están dispuestos a responder preguntas y ofrecer soluciones. He realizado evaluaciones en profundidad de herramientas alternativas y siempre volvemos a Memberstack: ahórrate el tiempo y dale una oportunidad"."
¿Necesitas ayuda con este MemberScript? ¡Únete a nuestra comunidad Slack!
Únete al Slack de la comunidad Memberstack y ¡pregunta! Espera una respuesta rápida de un miembro del equipo, un experto de Memberstack o un compañero de la comunidad.