From c2e9fa513d6d5247fba9a3a6847cdd29d6db4555 2021-11-06 19:58:27 From: Lance Edgar Date: 2021-11-06 19:58:27 Subject: [PATCH] Add `get_past_products()` method for custorder batch handler also add more to `get_product_info()` --- diff --git a/rattail/batch/custorder.py b/rattail/batch/custorder.py index 3d69ac183ebe650d6bab7b73f5a65dd722a20f2e..22347256647032a4438e0c02683fa94c760af7e0 100644 --- a/rattail/batch/custorder.py +++ b/rattail/batch/custorder.py @@ -410,20 +410,34 @@ class CustomerOrderBatchHandler(BatchHandler): "{}.custom_product_autocomplete() " "method.".format(__class__.__name__)) + def get_past_products(self, batch, **kwargs): + """ + Should return a (possibly empty) list of products which have + been ordered in the past by the customer who is associated + with the given batch. + """ + # TODO: should crawl the rattail order history here + return [] + def get_product_info(self, batch, product, **kwargs): """ Return a data dict containing misc. info pertaining to the given product, for the order batch. """ products = self.app.get_products_handler() + vendor = product.cost.vendor if product.cost else None info = { 'uuid': product.uuid, 'upc': six.text_type(product.upc), 'upc_pretty': product.upc.pretty(), - 'full_description': product.full_description, + 'brand_name': product.brand.name if product.brand else None, + 'description': product.description, 'size': product.size, + 'full_description': product.full_description, 'case_quantity': self.app.render_quantity(self.get_case_size_for_product(product)), 'unit_price_display': products.render_price(product.regular_price), + 'department_name': product.department.name if product.department else None, + 'vendor_name': vendor.name if vendor else None, 'image_url': products.get_image_url(product), 'uom_choices': self.uom_choices_for_product(product), }