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 = {}) {
|
||||
const variant = await this.productVariantService_.retrieve(variantId, {
|
||||
return this.atomicPhase_(async manager => {
|
||||
const variant = await this.productVariantService_
|
||||
.withTransaction(manager)
|
||||
.retrieve(variantId, {
|
||||
relations: ["product"],
|
||||
})
|
||||
|
||||
const region = await this.regionService_.retrieve(regionId)
|
||||
const region = await this.regionService_
|
||||
.withTransaction(manager)
|
||||
.retrieve(regionId)
|
||||
|
||||
let price
|
||||
let shouldMerge = true
|
||||
@@ -109,10 +114,9 @@ class LineItemService extends BaseService {
|
||||
price = config.unit_price
|
||||
}
|
||||
} else {
|
||||
price = await this.productVariantService_.getRegionPrice(
|
||||
variant.id,
|
||||
region.id
|
||||
)
|
||||
price = await this.productVariantService_
|
||||
.withTransaction(manager)
|
||||
.getRegionPrice(variant.id, region.id)
|
||||
}
|
||||
|
||||
const toCreate = {
|
||||
@@ -122,13 +126,14 @@ class LineItemService extends BaseService {
|
||||
thumbnail: variant.product.thumbnail,
|
||||
variant_id: variant.id,
|
||||
quantity: quantity || 1,
|
||||
allow_discounts: !variant.product.is_giftcard,
|
||||
allow_discounts: variant.product.discountable,
|
||||
is_giftcard: variant.product.is_giftcard,
|
||||
metadata: config?.metadata || {},
|
||||
should_merge: shouldMerge,
|
||||
}
|
||||
|
||||
return toCreate
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user