vuestorefront / vue-storefront-1

The open-source frontend for any eCommerce. Built with a PWA and headless approach, using a modern JS stack. We have custom integrations with Magento, commercetools, Shopware and Shopify and total coverage is just a matter of time. The API approach also allows you to merge VSF with any third-party tool like CMS, payment gateways or analytics. Newest updates: https://blog.vuestorefront.io. Always Open Source, MIT license.
https://www.vuestorefront.io
MIT License
18 stars 13 forks source link

How to extend any core module. No proper documentation found #201

Closed bloodf closed 3 years ago

bloodf commented 3 years ago

From vue-storefront created by muhammad-abubakkar: vuestorefront/vue-storefront#5318

I want to override an action from cart module store. I am trying to extend this CartModule by following this link Extending and Overriding Modules Doc

I have created a file /src/modules/cart/index.ts with following code

import { VueStorefrontModuleConfig, extendModule, VueStorefrontModule } from '@vue-storefront/core/lib/module'
import { CartModule } from '@vue-storefront/core/modules/cart'

import { cartModule } from './store'

const cartExtend: VueStorefrontModuleConfig = {
    key: 'cart',
    store: {modules: [{key: 'cart', module: cartModule}]},
    afterRegistration: function () {
        console.log('Cart module extended')
    }
}

extendModule(cartExtend)

export const registerModules: VueStorefrontModule[] = [CartModule]

I am getting error that CarModule type does not match with VueStorefrontModule

Also I don't know what to do next in order to make it effective. Docs are not clear about it. Please help. Thanks