def get_warning(self): """ Return a warning message about this basket line if one is applicable This could be things like the price has changed """ if not self.price_incl_tax: return if not self.product.has_stockrecord: msg = u"'%(product)s' is no longer available" return _(msg) % {'product': self.product.get_title()} current_price_incl_tax = self.product.stockrecord.price_incl_tax if current_price_incl_tax > self.price_incl_tax: msg = ("The price of '%(product)s' has increased from " "%(old_price)s to %(new_price)s since you added it " "to your basket") return _(msg) % { 'product': self.product.get_title(), 'old_price': currency(self.price_incl_tax), 'new_price': currency(current_price_incl_tax)} if current_price_incl_tax < self.price_incl_tax: msg = ("The price of '%(product)s' has decreased from " "%(old_price)s to %(new_price)s since you added it " "to your basket") return _(msg) % { 'product': self.product.get_title(), 'old_price': currency(self.price_incl_tax), 'new_price': currency(current_price_incl_tax)}
def _create_group_product_fields(self, item): """ Adds the fields for a "group"-type product (eg, a parent product with a list of variants. """ choices = [] for variant in item.variants.all(): if variant.has_stockrecord: attr_summary = variant.attribute_summary() if attr_summary: attr_summary = "(%s)" % attr_summary summary = u"%s %s - %s" % ( variant.get_title(), attr_summary, currency(variant.stockrecord.price_incl_tax)) choices.append((variant.id, summary)) self.fields['product_id'] = forms.ChoiceField( choices=tuple(choices), label=_("Variant"))