Did you ever figure this out? I'm in a similar boat where I'd like to have a free plan with no trials and have the free plan be selected by default after registering.
Change default plan
Right now, the default plan on the register page is the first paid plan that I have. I want to make it so that the free plan is selected. The logic for this isn't in a component file, it's in mixins/register.js, so it can't be overridden using the method described in the docs.
I tried adding code to re-select the free plan in resources/assets/js/spark-components/auth/register-stripe.js, but this executes before the plan selection logic as it retrieves the plan list via ajax first.
How can I do this without directly editing the code?
I needed this, too. Here is how it works and how it can be solved.
How it works:
there is a selectAppropriateDefaultPlan()-method in the vendor\laravel\spark\resources\assets\js\mixins\register.js file that is responsible for selecting the default plan.
/**
* Select the appropriate default plan for registration.
*/
selectAppropriateDefaultPlan() {
if (this.monthlyPlans.length == 0 && this.yearlyPlans.length > 0) {
this.showYearlyPlans();
}
if (this.query.plan) {
this.selectPlanByName(this.query.plan);
} else if (this.query.invitation) {
this.selectFreePlan();
} else if (this.paidPlansForActiveInterval.length > 0) {
this.selectPlan(this.paidPlansForActiveInterval[0]);
} else {
this.selectFreePlan();
}
}
As it is not such a good idea to overwrite it in the vendor files I edited my \resources\assets\js\spark-components\auth\register-stripe.js - because I use stripe.
As far as I understand that is the intended way of overwriting spark .js methods - correct me if I am wrong!
So now it looks like this:
var base = require('auth/register-stripe');
Vue.component('spark-register-stripe', {
mixins: [base],
methods: {
/**
* Select the appropriate default plan for registration.
* Partially overwriting laravel\spark\resoures\assets\js\mixins\register.js to set free plan as default plan
*/
selectAppropriateDefaultPlan() {
this.selectFreePlan();
}
}
});
Don't forget to run GULP - and it shoud work.
That's it. (you must have a free plan as it is now hardcoded as default)
Please or to participate in this conversation.