From 6ea1859f82fdde343be5d7d649d40e43223395e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Sun, 12 Mar 2023 11:08:10 +0800 Subject: Order now takes only SKU --- interchange.cxx | 5 +---- interchange.hxx | 12 +++++------- ord.cxx | 4 ++-- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/interchange.cxx b/interchange.cxx index 9833b1d..2daba1e 100644 --- a/interchange.cxx +++ b/interchange.cxx @@ -82,12 +82,9 @@ namespace QInterchange { emit gotOrder(response); } - void Interchange::order(QString const& sku, Catalog const& catalog, - Ord& order) + void Interchange::order(QString const& sku) { - auto data = order.data(); interchange_ord_order(sku.toLatin1().constData(), - catalog.constData(), &data, [](interchange_response* response) { interchange->emitOrder(QString{response->data}); interchange_free_response(response); diff --git a/interchange.hxx b/interchange.hxx index 8a4dfc3..b8b36d5 100644 --- a/interchange.hxx +++ b/interchange.hxx @@ -28,13 +28,6 @@ namespace QInterchange { * \brief Destructor. */ ~Interchange(); - /*! - * \brief For putting an item to a cart. - * \param sku The SKU of the item to order. - * \param catalog The catalog from which the item is. - * \param order The order. - */ - void order(QString const& sku, Catalog const& catalog, Ord& order); public slots: /*! @@ -65,6 +58,11 @@ namespace QInterchange { * \brief For fetching data about all active products. */ void defaultAllProducts(); + /*! + * \brief For putting an item to a cart. + * \param sku The SKU of the item to order. + */ + void order(QString const& sku); signals: void gotCatalog(QString const& response); diff --git a/ord.cxx b/ord.cxx index f1cfcac..9d27432 100644 --- a/ord.cxx +++ b/ord.cxx @@ -15,12 +15,12 @@ namespace QInterchange { m_totalCost{.0} { ord = this; - if (order) return; + if (!order) return; for (size_t i = 0; i < order->nitems; i++) addItem(Item{order->items[i]}); m_subtotal = order->subtotal; m_totalCost = order->total_cost; - this->m_data = order; + m_data = order; } Ord::~Ord() -- cgit v1.2.3