How can we add product to cart from custom module

Hello everyone,
i have created custom module to list products in customer my account section and now i want to add the product to cart from my account section. can anyone tell me how can i add product to cart from custom module if i have product sku and product id available?
thanks in advance.

Hi there! You can easily add the product to cart via dispatching the Vuex action:

From the component level:

this.$store.dispatch('cart/addItem', { productToAdd: { sku: `SKU value`, qty: 1 })

From the any other place:
import rootStore from @vue-storefront/store
rootStore.dispatch(‘cart/addItem’, { productToAdd: { sku: SKU value, qty: 1 })

hello @pkarw, thanks for replay, We have already tried this but when adding product to cart there will be only single call made to check product stock then rest of the call are not executed and process stops after this call. do you have any idea?