summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-03-12 17:46:34 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-03-12 17:46:34 +0800
commitf70a1a57d83e4f50a7221d13b173a156ef0eb6cf (patch)
treeb2dc619e44eee4a1328cca2abb5a926cc7f55666
parent628fbf1304bff4de9be752d2f4be77d58a5ab689 (diff)
Checkout needs only profile from order
-rw-r--r--interchange/ord.hxx1
-rw-r--r--ord.cxx11
2 files changed, 7 insertions, 5 deletions
diff --git a/interchange/ord.hxx b/interchange/ord.hxx
index 2d18891..56bb7d3 100644
--- a/interchange/ord.hxx
+++ b/interchange/ord.hxx
@@ -62,6 +62,7 @@ namespace QInterchange {
void addItem(Item const& item);
QList<Item> items;
struct interchange_ord_order* m_data;
+ QString profile;
double m_subtotal;
double m_shipping;
double m_totalCost;
diff --git a/ord.cxx b/ord.cxx
index 9d27432..f7e2161 100644
--- a/ord.cxx
+++ b/ord.cxx
@@ -6,6 +6,7 @@
namespace QInterchange {
static Ord* ord;
+ static char* order_profile;
Ord::Ord(struct interchange_ord_order *order, QObject* parent) :
QAbstractListModel{parent},
@@ -89,16 +90,16 @@ namespace QInterchange {
void Ord::setProfile(QString const& profile)
{
- auto orderProfile = profile.toLatin1().data();
- if (m_data->profile) free(m_data->profile);
- m_data->profile = (char*)malloc(strlen(orderProfile) + 1);
- strcpy(m_data->profile, orderProfile);
+ if (this->profile != profile) this->profile = profile;
}
void Ord::checkout(Member& member)
{
- interchange_ord_checkout(m_data, member.data(),
+ order_profile = (char*)malloc(profile.size() + 1);
+ strcpy(order_profile, profile.toLatin1().constData());
+ interchange_ord_checkout(order_profile, member.data(),
[](interchange_response* response) {
+ free(order_profile);
ord->emitTransaction(QString{response->data});
interchange_free_response(response);
});