from oscar.apps.shipping import repository, methods from oscar.apps.offer import models from oscar.apps.offer.custom import create_condition class TakeAway(models.Condition): name = "User must be called barry" class Meta: proxy = True def is_satisfied(self, offer, basket): print offer return True create_condition(TakeAway) # We create subclasses so we can give them different codes and names class Standard(methods.Free): code = 'delivery' name = "Delivery shipping" class Express(methods.Free): code = 'takeaway' name = "Takeaway shipping" class Repository(repository.Repository): methods = [Standard(), Express()] def get_shipping_methods(self, user, basket, shipping_addr=None, **kwargs): return self.prime_methods(basket, self.methods) def find_by_code(self, code, basket): for method in self.methods: if code == method.code: return self.prime_method(basket, method)