extended add to wishlist with metadata
This commit is contained in:
@@ -38,6 +38,7 @@ export default () => {
|
|||||||
const schema = Validator.object().keys({
|
const schema = Validator.object().keys({
|
||||||
variant_id: Validator.string().required(),
|
variant_id: Validator.string().required(),
|
||||||
quantity: Validator.number().required(),
|
quantity: Validator.number().required(),
|
||||||
|
metadata: Validator.object().optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
const { value, error } = schema.validate(req.body)
|
const { value, error } = schema.validate(req.body)
|
||||||
@@ -57,7 +58,8 @@ export default () => {
|
|||||||
const lineItem = await lineItemService.generate(
|
const lineItem = await lineItemService.generate(
|
||||||
value.variant_id,
|
value.variant_id,
|
||||||
regions[0].id,
|
regions[0].id,
|
||||||
value.quantity
|
value.quantity,
|
||||||
|
{ metadata: value.metadata }
|
||||||
)
|
)
|
||||||
|
|
||||||
const wishlist = (customer.metadata && customer.metadata.wishlist) || []
|
const wishlist = (customer.metadata && customer.metadata.wishlist) || []
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class LineItemService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async generate(variantId, regionId, quantity, config = {}) {
|
async generate(variantId, regionId, quantity, config = {}) {
|
||||||
return this.atomicPhase_(async manager => {
|
return this.atomicPhase_(async (manager) => {
|
||||||
const variant = await this.productVariantService_
|
const variant = await this.productVariantService_
|
||||||
.withTransaction(manager)
|
.withTransaction(manager)
|
||||||
.retrieve(variantId, {
|
.retrieve(variantId, {
|
||||||
@@ -142,7 +142,7 @@ class LineItemService extends BaseService {
|
|||||||
* @return {LineItem} the created line item
|
* @return {LineItem} the created line item
|
||||||
*/
|
*/
|
||||||
async create(lineItem) {
|
async create(lineItem) {
|
||||||
return this.atomicPhase_(async manager => {
|
return this.atomicPhase_(async (manager) => {
|
||||||
const lineItemRepository = manager.getCustomRepository(
|
const lineItemRepository = manager.getCustomRepository(
|
||||||
this.lineItemRepository_
|
this.lineItemRepository_
|
||||||
)
|
)
|
||||||
@@ -160,7 +160,7 @@ class LineItemService extends BaseService {
|
|||||||
* @return {LineItem} the update line item
|
* @return {LineItem} the update line item
|
||||||
*/
|
*/
|
||||||
async update(id, update) {
|
async update(id, update) {
|
||||||
return this.atomicPhase_(async manager => {
|
return this.atomicPhase_(async (manager) => {
|
||||||
const lineItemRepository = manager.getCustomRepository(
|
const lineItemRepository = manager.getCustomRepository(
|
||||||
this.lineItemRepository_
|
this.lineItemRepository_
|
||||||
)
|
)
|
||||||
@@ -188,7 +188,7 @@ class LineItemService extends BaseService {
|
|||||||
* @return {Promise} the result of the delete operation
|
* @return {Promise} the result of the delete operation
|
||||||
*/
|
*/
|
||||||
async delete(id) {
|
async delete(id) {
|
||||||
return this.atomicPhase_(async manager => {
|
return this.atomicPhase_(async (manager) => {
|
||||||
const lineItemRepository = manager.getCustomRepository(
|
const lineItemRepository = manager.getCustomRepository(
|
||||||
this.lineItemRepository_
|
this.lineItemRepository_
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user