diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2023-06-16 15:40:24 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2023-06-16 15:40:24 +0800 |
commit | 4c43c27774cfc3652ff3269519ee248e71b58185 (patch) | |
tree | be2c03a23347033a16926e236d0af93d8ca27d7f /ord.cxx | |
parent | d0a8570fd5c46ad2cab21af0b8f5a299bcbc1792 (diff) |
Item is now a subclass of Product
Diffstat (limited to 'ord.cxx')
-rw-r--r-- | ord.cxx | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -16,7 +16,7 @@ namespace QInterchange { { ord = this; for (size_t i = 0; i < order->nitems; i++) - addItem(Item{order->items[i]}); + addItem(Item{&order->items[i]}); m_subtotal = order->subtotal; m_shipping = order->shipping; m_totalCost = order->total_cost; @@ -35,17 +35,17 @@ namespace QInterchange { auto item = items[row]; switch (role) { case Product::SkuRole: - return item.product.sku; + return item.sku; case Product::TitleRole: - return item.product.title; + return item.title; case Product::DescriptionRole: - return item.product.description; + return item.description; case Product::ImageRole: - return item.product.image; + return item.image; case Product::PriceRole: - return item.product.price; + return item.price; case Product::OptionTypeRole: - return item.product.optionType; + return item.optionType; case Item::QuantityRole: return item.quantity; case Item::NameRole: @@ -71,9 +71,10 @@ namespace QInterchange { void Ord::addItem(Item const& item) { - auto product = item.product; - auto iterator = std::find_if(items.begin(), items.end(), [&product](Item const& item) { - return product.sku == item.product.sku; + auto sku = item.sku; + auto iterator = std::find_if(items.begin(), items.end(), + [&sku](Item const& item) { + return sku == item.sku; }); if (iterator != items.end()) { auto index = items.indexOf(*iterator); |