Stripe subscriptions
Important!
It is only necessary to add the code below to your theme if you are using a Version 2 or Version 1 theme. Users of Version 3, Version 4 and Version 5 themes do not need to install any code to use these features.
We have provided instructions below on what code needs to be added to your website to use the Subscription system, but we can install this for you for a one-off cost. To request we install the code for you, select the 'request installation' button on the Stripe Subscriptions app installation page.
1. You may like to display certain text or a certain graphic on your website if a product is a subscription product. This can be done by using the 'subscription' variable, e.g.
{% if product.subscription %} some content here... {% endif %}
2. You can display the subscription interval (e.g. monthly, weekly) with the subscription_interval variable, e.g.
{{ product.subscription_interval }}
3. On the shopping basket page, customers that have both subscription and one-off products in their basket need to be informed that they cannot complete checkout with both. A message can be outputted using the has_both_normal_and_subscription_products variable
{% if basket.errors.has_both_normal_and_subscription_products %} some content here... {% endif %}
4. The customer will need to be directed through to the checkout/login page on your website, by posting the checkout form on checkout/basket to /checkout/login. You can use the same variable described in (3) above.
5. On the checkout/login page you need to hide the checkout as a guest option (if this is enabled on your website in the theme settings) with the has_subscription_products variable.
6. You can create two new 'account' pages within your website for
/account/subscriptions
/account/subscription/{{ ID }}
To display, on the 'subscriptions' page, a list of all the subscriptions the user has created, and 'on the subscription' page, details of the subscription.
7. Create a twig file account_subscriptions.twig. You can copy and paste the contents of the account_orders.twig file as a base and make some modifications.
To output the subscriptions setup on a customer's account you can use the subscriptions object {% for subscription in subscriptions %}
Within each subscription you can reference
subscription.created - the date the subscription was created
subscription.total_amount - the total amount of the subscription
subscription.id - the ShopWired generated ID for the subscription
subscription.status - the status of the subscription (active or cancelled)
A link for the customer to view the individual details about the subscription can be provided using the format /account/subscription/{{ subscription.id }}.
8. Create another twig file account_subscription.twig for customers to view individual details about a subscription (e.g. the products ordered).
Again, you can use the subscription object to reference the subscription information (as described above).
Some additional variables you can use are:
billing_name, billing_email, billing_postcode, billing_country, billing_state, billing_address1, billing_address2, billing_address3, billing_city, billing_company, billing_phone
shipping_name, shipping_email, shipping_postcode, shipping_country, shipping_state, shipping_address1, shipping_address2, shipping_address3, shipping_city, shipping_company, shipping_phone
You can loop through the products in the subscription using {% for product in order.products %} and using the order products object.
9. You can create a cancel button on the subscription page
{% if subscription.status == 'active' %} <form action="/account/subscription/{{ subscription.id }}" method="post"> <button type="submit" name="cancel" value="1" onclick="return confirm('Confirm?')"> Cancel </button> </form> {% endif %}