GitHub

DaffMagentoCartService

import { DaffMagentoCartService } from '@daffodil/cart/driver/magento'

A service for making Magento GraphQL queries for carts.

@Injectable()
class DaffMagentoCartService implements DaffCartServiceInterface<DaffCart> {
  get(cartId: string): Observable<DaffDriverResponse<DaffCart>>
  create(): Observable<{
      id: DaffCart['id'];
  }>
  addToCart(
    productId: string
    qty: number
  ): Observable<DaffCart>
  clear(cartId: string): Observable<Partial<DaffCart>>
  merge(
    guestCart: string
    customerCart?: string
  ): Observable<DaffDriverResponse<DaffCart>>
}

() Methods

get
Observable<DaffDriverResponse<DaffCart>>

Retrieve a cart.

@param id The cart ID.

Parameters
ParametercartId: string
Description
create
Observable<{ id: DaffCart['id']; }>

Creates a cart.

addToCart
Observable<DaffCart>
Parameters
ParameterproductId: string
Description
Parameterqty: number
Description
clear
Observable<Partial<DaffCart>>

Remove all items from a cart.

Parameters
ParametercartId: string
Description
merge
Observable<DaffDriverResponse<DaffCart>>

Merge a guest cart into a customer cart.

Parameters
ParameterguestCart: string
Description
ParametercustomerCart: string
Description