def get_shipping_method(self, basket, shipping_address=None, **kwargs): """ Return the shipping method used """ if not basket.is_shipping_required(): return NoShippingRequired() # Instantiate a new FixedPrice shipping method instance charge_incl_tax = D(self.txn.value('PAYMENTREQUEST_0_SHIPPINGAMT')) # Assume no tax for now charge_excl_tax = charge_incl_tax name = self.txn.value('SHIPPINGOPTIONNAME') session_method = super(SuccessResponseView, self).get_shipping_method( basket, shipping_address, **kwargs) if not session_method or (name and name != session_method.name): if name: method = self._get_shipping_method_by_name(name, basket, shipping_address) else: method = None if not method: method = FixedPrice(charge_excl_tax, charge_incl_tax) if session_method: method.name = session_method.name method.code = session_method.code else: method = session_method return method
def get_shipping_method(self, basket=None): """ Return the shipping method used """ charge = D(self.txn.value('PAYMENTREQUEST_0_SHIPPINGAMT')) method = FixedPrice(charge) basket = basket if basket else self.request.basket method.set_basket(basket) name = self.txn.value('SHIPPINGOPTIONNAME') if not name: # Look to see if there is a method in the session session_method = self.checkout_session.shipping_method(basket) if session_method: method.name = session_method.name else: method.name = name return method
def get_shipping_method(self, basket=None): """ Return the shipping method used """ charge = D(self.txn.value('PAYMENTREQUEST_0_SHIPPINGAMT')) method = FixedPrice(charge) basket = basket if basket else self.request.basket method.set_basket(basket) method.name = self.txn.value('SHIPPINGOPTIONNAME') return method
def get_shipping_method(self, basket=None, shipping_address=None, **kwargs): """ Return the shipping method used """ # Instantiate a new FixedPrice shipping method instance charge_incl_tax = D(self.txn.value('PAYMENTREQUEST_0_SHIPPINGAMT')) # Assume no tax for now charge_excl_tax = charge_incl_tax method = FixedPrice(charge_excl_tax, charge_incl_tax) method.set_basket(basket) name = self.txn.value('SHIPPINGOPTIONNAME') if not name: # Look to see if there is a method in the session session_method = super(SuccessResponseView, self).get_shipping_method(basket, shipping_address) if session_method: method.name = session_method.name else: method.name = name return method
def get_shipping_method(self, basket, shipping_address=None, **kwargs): """ Return the shipping method used """ if not basket.is_shipping_required(): return NoShippingRequired() # Instantiate a new FixedPrice shipping method instance charge_incl_tax = D(self.txn.value('PAYMENTREQUEST_0_SHIPPINGAMT')) # Assume no tax for now charge_excl_tax = charge_incl_tax method = FixedPrice(charge_excl_tax, charge_incl_tax) method.set_basket(basket) name = self.txn.value('SHIPPINGOPTIONNAME') if not name: # Look to see if there is a method in the session session_method = self.checkout_session.shipping_method_code(basket) if session_method: method.name = session_method #.name else: method.name = name return method
from decimal import Decimal as D from oscar.apps.shipping.methods import FixedPrice, NoShippingRequired from oscar.apps.shipping.repository import Repository as CoreRepository # Dummy shipping methods method1 = FixedPrice(D('12.00')) method1.code = 'method1' method1.name = 'Ship by van' method2 = FixedPrice(D('24.00')) method2.code = 'method2' method2.name = 'Ship by pigeon' method2.description = 'Here is a description of this shipping method' class Repository(CoreRepository): methods = { method1.code: method1, method2.code: method2, } def get_shipping_methods(self, user, basket, shipping_addr=None, **kwargs): methods = self.methods.values() return self.prime_methods(basket, methods) def find_by_code(self, code, basket): if code == NoShippingRequired.code: method = NoShippingRequired() else: method = self.methods.get(code, None) return self.prime_method(basket, method)