Changeset - c2e9fa513d6d
[Not reviewed]
0 1 0
Lance Edgar (lance) - 3 years ago 2021-11-06 19:58:27
lance@edbob.org
Add `get_past_products()` method for custorder batch handler

also add more to `get_product_info()`
1 file changed with 15 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rattail/batch/custorder.py
Show inline comments
 
@@ -407,26 +407,40 @@ class CustomerOrderBatchHandler(BatchHandler):
 
        should be a dict with "label" and "value" keys.
 
        """
 
        raise NotImplementedError("Please define the "
 
                                  "{}.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),
 
        }
 

	
 
        case_price = None
 
        if product.regular_price and product.regular_price is not None:
0 comments (0 inline, 0 general)