Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

renedekat's avatar

Laravel Spark override mixin data param

Hi,

I was wondering how I can override a mixin data param. I would like to change the default billing country from US to GB.

The mixin is: subscribe-stripe.js with data function


    data() {
        return {
            taxRate: 0,

            form: new SparkForm({
                stripe_token: '',
                plan: '',
                coupon: null,
                address: '',
                address_line_2: '',
                city: '',
                state: '',
                zip: '',
                country: 'US',
                vat_id: ''
            }),

            cardForm: new SparkForm({
                name: '',
                number: '',
                cvc: '',
                month: '',
                year: '',
                zip: ''
            })
        };
    },

Which I would like to override in subscribe-stripe.js with the contents:

var base = require('settings/subscription/subscribe-stripe');

Vue.component('spark-subscribe-stripe', {
    mixins: [base]
});

I can override the entire file, but that's a bit overkill for just 1 value :)

0 likes
1 reply
renedekat's avatar
renedekat
OP
Best Answer
Level 14

I found the solution. As it turns out the mixin calls a initializeBillingAddress method which sets the country to this.billable.billing_country || 'US'

By adding a created() to set the billing_country I was able to set the default to 'GB'

New code:

var base = require('settings/subscription/subscribe-stripe');

Vue.component('spark-subscribe-stripe', {
    mixins: [base],

    created: function() {
        this.billable.billing_country = this.billable.billing_country || 'GB';
    }
});
2 likes

Please or to participate in this conversation.