def apply_for_basket(self, order_source): from shuup.campaigns.models import CatalogCampaign campaign = self.campaign supplier = campaign.supplier if hasattr(campaign, "supplier") and campaign.supplier else None discounted_base_amount = get_total_price_of_products(order_source, campaign) context = PricingContext(order_source.shop, order_source.customer) for line in order_source.get_product_lines(): if supplier and line.supplier != supplier: continue product = line.product if CatalogCampaign.get_matching(context, product.get_shop_instance(order_source.shop)): discounted_base_amount -= line.price return (discounted_base_amount * self.value)
def apply_for_basket(self, order_source): from shuup.campaigns.models import CatalogCampaign campaign = self.campaign supplier = campaign.supplier if hasattr(campaign, "supplier") and campaign.supplier else None discounted_base_amount = get_total_price_of_products(order_source, campaign) context = PricingContext(order_source.shop, order_source.customer) for line in order_source.get_product_lines(): if supplier and line.supplier != supplier: continue product = line.product if CatalogCampaign.get_matching(context, product.get_shop_instance(order_source.shop)): discounted_base_amount -= line.price return discounted_base_amount * self.value
def matches(self, basket, lines): from shuup.campaigns.models import CatalogCampaign campaign = self.campaign.first() total_of_products = get_total_price_of_products(basket, campaign) product_lines = basket.get_product_lines() if hasattr(campaign, "supplier") and campaign.supplier: product_lines = [line for line in product_lines if line.supplier == campaign.supplier] total_undiscounted_price_value = total_of_products.value shop = basket.shop context = PricingContext(shop, basket.customer) for line in product_lines: if CatalogCampaign.get_matching(context, line.product.get_shop_instance(shop)): total_undiscounted_price_value -= line.price.value return (total_undiscounted_price_value >= self.amount_value)
def matches(self, basket, lines): from shuup.campaigns.models import CatalogCampaign campaign = self.campaign.first() total_of_products = get_total_price_of_products(basket, campaign) product_lines = basket.get_product_lines() if hasattr(campaign, "supplier") and campaign.supplier: product_lines = [ line for line in product_lines if line.supplier == campaign.supplier ] total_undiscounted_price_value = total_of_products.value shop = basket.shop context = PricingContext(shop, basket.customer) for line in product_lines: if CatalogCampaign.get_matching( context, line.product.get_shop_instance(shop)): total_undiscounted_price_value -= line.price.value return (total_undiscounted_price_value >= self.amount_value)
def apply_for_basket(self, order_source): total_price_of_products = get_total_price_of_products( order_source, self.campaign) return (total_price_of_products * self.value)
def matches(self, basket, lines): campaign = self.campaign.first() total_of_products = get_total_price_of_products(basket, campaign) return (total_of_products.value >= self.amount_value)
def apply_for_basket(self, order_source): total_price_of_products = get_total_price_of_products(order_source, self.campaign) return (total_price_of_products * self.value)