1
Fork 0
mirror of https://github.com/Steffo99/greed.git synced 2024-11-22 14:04:18 +00:00
This commit is contained in:
Steffo 2020-04-04 13:06:57 +02:00
parent 9688575fd7
commit 5828ba8f31

View file

@ -408,7 +408,9 @@ class ChatWorker(threading.Thread):
caption=product.text(cart_qty=cart[callback.message.message_id][1]), caption=product.text(cart_qty=cart[callback.message.message_id][1]),
reply_markup=product_inline_keyboard) reply_markup=product_inline_keyboard)
self.bot.edit_message_text(chat_id=self.chat.id, message_id=final_msg.message_id, self.bot.edit_message_text(
chat_id=self.chat.id,
message_id=final_msg.message_id,
text=strings.conversation_confirm_cart.format(product_list=self.__get_cart_summary(cart), text=strings.conversation_confirm_cart.format(product_list=self.__get_cart_summary(cart),
total_cost=str(self.__get_cart_value(cart))), total_cost=str(self.__get_cart_value(cart))),
reply_markup=final_inline_keyboard) reply_markup=final_inline_keyboard)
@ -450,7 +452,9 @@ class ChatWorker(threading.Thread):
caption=product.text(cart_qty=cart[callback.message.message_id][1]), caption=product.text(cart_qty=cart[callback.message.message_id][1]),
reply_markup=product_inline_keyboard) reply_markup=product_inline_keyboard)
self.bot.edit_message_text(chat_id=self.chat.id, message_id=final_msg.message_id, self.bot.edit_message_text(
chat_id=self.chat.id,
message_id=final_msg.message_id,
text=strings.conversation_confirm_cart.format(product_list=self.__get_cart_summary(cart), text=strings.conversation_confirm_cart.format(product_list=self.__get_cart_summary(cart),
total_cost=str(self.__get_cart_value(cart))), total_cost=str(self.__get_cart_value(cart))),
reply_markup=final_inline_keyboard) reply_markup=final_inline_keyboard)
@ -489,14 +493,16 @@ class ChatWorker(threading.Thread):
# User has credit and valid order, perform transaction now # User has credit and valid order, perform transaction now
self.__order_transaction(order=order, value=-int(self.__get_cart_value(cart))) self.__order_transaction(order=order, value=-int(self.__get_cart_value(cart)))
def __get_cart_value(self, cart): @staticmethod
def __get_cart_value(cart):
# Calculate total items value in cart # Calculate total items value in cart
value = utils.Price(0) value = utils.Price(0)
for product in cart: for product in cart:
value += cart[product][0].price * cart[product][1] value += cart[product][0].price * cart[product][1]
return value return value
def __get_cart_summary(self, cart): @staticmethod
def __get_cart_summary(cart):
# Create the cart summary # Create the cart summary
product_list = "" product_list = ""
for product_id in cart: for product_id in cart: