1

I'm trying to make a 2-step subscription process. Where someone clicks 'subscribe' and it takes them to a new page.

Free trial button goes to url('subscribe?plan=' ~ plan.uid)

I then retrieve that on the subscribe page with {% set plan = craft.app.request.getParam('plan') %}

How can I pass that UID into the gateway form? I use {{ plan.gateway.getPaymentFormHtml({})|raw }} but get Impossible to access an attribute ("gateway") on a string variable ("2c98700c-0839232").

Makes sense but I'm looking for a way to get the plan via the planUid. This is where my head goes, but I know it's not correct:

{% set chosenPlan = craft.app.request.getParam('plan') %}
{% set plan = craft.commerce.getPlans().getAllPlans().uid(chosenPlan) %}
{{ plan.gateway.getPaymentFormHtml({})|raw }}

Does anyone know how I could get this (or something like it) to work?

1 Answer 1

1

Got it!

{% set chosenPlan = craft.app.request.getParam('plan') %}
{% set plan = craft.commerce.getPlans().getPlanByUid(chosenPlan) %}
{{ plan.gateway.getPaymentFormHtml({})|raw }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.