Is there a way to see if a customer has an active subscription through liquid?
Something like
{% if customer.active_subscription %}
etc.
Thanks,
Is there a way to see if a customer has an active subscription through liquid?
Something like
{% if customer.active_subscription %}
etc.
Thanks,
Hi @avanor !
The customer object in Liquid does not have an attribute for āactive subscriptionā, but you can certainly use the customer object to do things like checking if the customer has an account or if they have opted-in for marketing: https://shopify.dev/docs/themes/liquid/reference/objects/customer
From my understanding youād need to loop through a customerās orders and check to see if any of the orders contain selling plan line items: https://shopify.dev/tutorials/storefront-ux-guidelines-for-subscriptions#order-details. I personally do not have much experience with Shopifyās new subscription feature, so maybe someone else can chime in with more detailsā¦
Hopefully this helps!
{% if customer.accepts_marketing == true %}
Do something...
{% else %}
Do something else...
{% endif %}
Another way is to add tag to a customer when customer subscribe and then check this looping though tags⦠Something like:
{% assign is_subscription_customer = false %}
{% for tag in customer.tags %}
{% if tag == 'Active Subscriber' %}{% assign is_subscription_customer = true %}{% break %}{% endif %}
{% endfor %}
{% if is_subscription_customer %}
{% else %}
{% endif %}
Iāve used first method only, but Iām sure second one works toā¦
Hope this helps
Hi there,
thanks for the answers. @MarinaP your solution requires that your assigment works in every case, i am not so happy with this āhackā. I am also struggling to get active subscriptions in liquid. Is there any way to achieve this with the new theme app extensions?
I want to assign a liquid variable the result fo the GraphQL Query :
query {
subscriptionContracts(first: 10) {
edges {
node {
id
createdAt
status
nextBillingDate
customer {
firstName
lastName
}
billingPolicy {
interval
intervalCount
}
}
}
}
}