Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-dudarev committed Nov 12, 2024
1 parent 21f21a9 commit 6a15605
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ protected override async Task UpdateQuoteAsync(QuoteRequest quote, AddQuoteItems
StoreId = quote.StoreId,
CurrencyCode = quote.Currency,
ObjectIds = productIds,
IncludeFields = new string[]
{
IncludeFields =
[
"__object",
"price",
"images",
"properties",
"description",
"slug",
"outlines"
},
],
EvaluatePromotions = false,
};

Expand All @@ -57,12 +57,13 @@ protected virtual void AddQuoteItems(QuoteRequest quote, AddQuoteItemsCommand re
{
var quoteItem = AbstractTypeFactory<QuoteItem>.TryCreateInstance();

var product = productsByIds.GetValueSafe(newQuoteItem.ProductId);
var price = product?.AllPrices.FirstOrDefault();

quoteItem.ProductId = newQuoteItem.ProductId;
quoteItem.Name = newQuoteItem.Name;
quoteItem.Comment = newQuoteItem.Comment;
quoteItem.Quantity = newQuoteItem.Quantity;
quoteItem.Currency = quote.Currency;

quoteItem.ProductId = newQuoteItem.ProductId;
var product = productsByIds.GetValueSafe(newQuoteItem.ProductId);
if (product != null)
{
quoteItem.Name = product.IndexedProduct.Name;
Expand All @@ -73,14 +74,10 @@ protected virtual void AddQuoteItems(QuoteRequest quote, AddQuoteItemsCommand re
quoteItem.TaxType = product.IndexedProduct.TaxType;
}

var price = product?.AllPrices.FirstOrDefault();
quoteItem.ListPrice = price?.ListPrice.InternalAmount ?? 0;
quoteItem.SalePrice = price?.SalePrice.InternalAmount ?? 0;

quoteItem.Comment = newQuoteItem.Comment;
quoteItem.Currency = quote.Currency;

quoteItem.Quantity = newQuoteItem.Quantity;

var tierPrice = AbstractTypeFactory<TierPrice>.TryCreateInstance();
tierPrice.Price = newQuoteItem.Price ?? quoteItem.SalePrice;
tierPrice.Quantity = newQuoteItem.Quantity;
Expand Down

0 comments on commit 6a15605

Please sign in to comment.