def get_costs(self, service, source): four = source.create_price('4.00') five = source.create_price('5.00') if source.shipping_address and source.shipping_address.country == "SE": yield ServiceCost(five, base_price=four) else: yield ServiceCost(four)
def get_costs(self, service, source): """ Return costs for for this object. This should be implemented in subclass. This method is used to calculate price for ``ShippingMethod`` and ``PaymentMethod`` objects. :type service: Service :type source: shuup.core.order_creator.OrderSource :rtype: Iterable[ServiceCost] """ # we just calculate when this behavior component is attached to our MyCarrier if isinstance(service.carrier, MyCarrier): # You'll likely get these from some API if service.choice_identifier == "slow": yield ServiceCost(source.create_price(Decimal("10"))) elif service.choice_identifier == "fast": yield ServiceCost(source.create_price(Decimal("30")))