1.0.0 • Published 2 years ago

@makaira/storefront-shop-adapter-shopware6 v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

@makaira/storefront-shop-adapter-shopware6

This shop adapter can be used to connect your shopware6 shop with your storefront. This adapter is developed based on the shopware store-api.

Installation

yarn install @makaira/storefront-types @makaira/storefront-shop-adapter-shopware6

or

npm install @makaira/storefront-types @makaira/storefront-shop-adapter-shopware6

Adding to your project

Basic usage

import { StorefrontShopAdapterShopware6 } from '@makaira/storefront-shop-adapter-shopware6'

const client = new StorefrontShopAdapterShopware6({
  url: '<SHOPWARE6-API-BASE-URL>',
  accessToken: '<SHOPWARE6-API-TOKEN>',
})

You can find the correct access key within your admin panel's sales channel configuration in the section labeled API Access.

Usage with @makaira/storefront-react

import { StorefrontShopAdapterShopware6 } from '@makaira/storefront-shop-adapter-shopware6'
import { ShopProvider } from '@makaira/storefront-react'

const shopClient = new StorefrontShopAdapterShopware6({
  url: '<SHOPWARE6-API-BASE-URL>',
})

function Index() {
  return (
    <ShopProvider client={shopClient}>
      <App />
    </ShopProvider>
  )
}

In addition if you are using typescript in your project and want to get the correct autosuggestion you have to create a new declaration file (e.g index.d.ts) with the following content:

import '@makaira/storefront-react'
import { StorefrontShopAdapterShopware6 } from '@makaira/storefront-shop-adapter-shopware6'

declare module '@makaira/storefront-react' {
  interface StorefrontReactCustomClient {
    client: StorefrontShopAdapterShopware6
  }
}

Additional constructor arguments

ArgumentRequiredDescriptionType
urlrequiredThe base api url to made requests again.string
accessTokenrequiredidentifies the sales channelstring
storageoptionalA storage engine for persisting data. This is by default the LocalStorage that is working in SSR. On Server Side every read and write will not be performed but not creates an error.MakairaStorage

Feature map

FeatureAvailable
cart
- addItem
- getCart
- removeItem
- updateItem
review
- getReviews
- createReview
user
- login
- logout
- signup
- getUser
- forgotPassword
wishlist
- getWishlist
- addItem
- removeItem
- createWishlist
checkout
- getCheckout
- submit

Additional input properties

Cart

getCart

No additional properties

addItem

PropertyRequired/OptionalDescriptionType
product.idrequiredUnique identity of type of entity.string
goodrequiredWhen set to true, it indicates the line item is physical else it is virtual.boolean
referencedIdrequiredUnique identity of type of entity.string
typerequiredType refers to the entity type of an item whether it is product or promotion for instance.string
quantityOptionalNumber of items of product. Required when type = "product"number

removeItem

PropertyRequired/OptionalDescriptionType
product.idrequiredUnique identity of type of entity.string

updateItem

PropertyRequired/OptionalDescriptionType
product.idrequiredUnique identity of type of entity.string
quantityOptionalNumber of items of product changing. Required when type = "product"number

Review

getReviews

PropertyRequired/OptionalDescriptionType
product.idrequiredUnique identity of type of entity.string
paginationOptionalPaginate response itemsobject
search-queries: filter, associations, includes, total-count-mode, post-filter, query, sort, aggregations, grouping, fieldsOptionalQuery to filter response with conditionobject

createReview

PropertyRequired/OptionalDescriptionType
review.product.idRequiredUnique identity of type of entity.string
review.ratingRequiredThe review rating for the product.double
review.textRequiredThe content of review.string
titleRequiredThe title of the review.string
headlineoptionalAn optional headline for this review.string
emailoptionalThe email address of the review author. If not set, the email of the customer is chosen.string
nameoptionalThe name of the review author. If not set, the first name of the customer is chosen.string

User

getUser

No additional properties

login

PropertyRequired/OptionalDescriptionType
usernameRequiredEmail.string
passwordRequiredPassword.string

logout

No additional properties

signup

PropertyRequired/OptionalDescriptionType
usernameRequiredEmail of the customer.string
passwordRequiredPassword for the customer.string
firstNameRequiredCustomer first name.string
lastNameRequiredCustomer last name.string
storefrontUrlRequiredURL of the storefront for that registration. Used in confirmation emails.string
billingAddress.countryIdRequiredUnique identity of country.string
billingAddress.cityRequiredName of customer's city.string
billingAddress.streetRequiredName of customer's street.string

Other properties check on document

forgotPassword

PropertyRequired/OptionalDescriptionType
usernameRequiredEmail.string
storefrontUrlRequiredURL of the storefront to use for the generated reset link. It has to be a domain that is configured in the sales channel domain settings.string

Wishlist

getWishlist

PropertyRequired/OptionalDescriptionType
search-queries: filter, associations, includes, total-count-mode, post-filter, query, sort, aggregations, grouping, fieldsOptionalQuery to filter response with conditionobject

Other properties check on document

addItem

PropertyRequired/OptionalDescriptionType
productIdRequiredIdentifier of the product to be added.string

Other properties check on document

removeItem

PropertyRequired/OptionalDescriptionType
productIdRequiredThe identifier of the product to be removed from the wishlist.string

Other properties check on document

createWishlist

PropertyRequired/OptionalDescriptionType
productIdsOptionalList product id.array[string]

Other properties check on document