grap line item from develop
This commit is contained in:
1 parent
f34a099a77
commit
5261999d12
1 file changed
+12
-7
@@ -90,11 +90,16 @@ class LineItemService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async generate(variantId, regionId, quantity, config = {}) {
|
async generate(variantId, regionId, quantity, config = {}) {
|
||||||
const variant = await this.productVariantService_.retrieve(variantId, {
|
return this.atomicPhase_(async manager => {
|
||||||
|
const variant = await this.productVariantService_
|
||||||
|
.withTransaction(manager)
|
||||||
|
.retrieve(variantId, {
|
||||||
relations: ["product"],
|
relations: ["product"],
|
||||||
})
|
})
|
||||||
|
|
||||||
const region = await this.regionService_.retrieve(regionId)
|
const region = await this.regionService_
|
||||||
|
.withTransaction(manager)
|
||||||
|
.retrieve(regionId)
|
||||||
|
|
||||||
let price
|
let price
|
||||||
let shouldMerge = true
|
let shouldMerge = true
|
||||||
@@ -109,10 +114,9 @@ class LineItemService extends BaseService {
|
|||||||
price = config.unit_price
|
price = config.unit_price
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
price = await this.productVariantService_.getRegionPrice(
|
price = await this.productVariantService_
|
||||||
variant.id,
|
.withTransaction(manager)
|
||||||
region.id
|
.getRegionPrice(variant.id, region.id)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const toCreate = {
|
const toCreate = {
|
||||||
@@ -122,13 +126,14 @@ class LineItemService extends BaseService {
|
|||||||
thumbnail: variant.product.thumbnail,
|
thumbnail: variant.product.thumbnail,
|
||||||
variant_id: variant.id,
|
variant_id: variant.id,
|
||||||
quantity: quantity || 1,
|
quantity: quantity || 1,
|
||||||
allow_discounts: !variant.product.is_giftcard,
|
allow_discounts: variant.product.discountable,
|
||||||
is_giftcard: variant.product.is_giftcard,
|
is_giftcard: variant.product.is_giftcard,
|
||||||
metadata: config?.metadata || {},
|
metadata: config?.metadata || {},
|
||||||
should_merge: shouldMerge,
|
should_merge: shouldMerge,
|
||||||
}
|
}
|
||||||
|
|
||||||
return toCreate
|
return toCreate
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user