Esempio n. 1
0
def pay_ship_save(new_order,
                  cart,
                  contact,
                  shipping,
                  discount,
                  notes,
                  update=False):
    """
    Save the order details, first removing all items if this is an update.
    """
    if shipping:
        update_shipping(new_order, shipping, contact, cart)

    if not update:
        # Temp setting of the tax and total so we can save it
        new_order.total = Decimal('0.00')
        new_order.tax = Decimal('0.00')
        new_order.sub_total = cart.total
        new_order.method = 'Online'

    if discount:
        new_order.discount_code = discount
    else:
        new_order.discount_code = ""
    if notes:
        new_order.notes = notes
    update_orderitems(new_order, cart, update=update)
Esempio n. 2
0
def update_shipping_cost_for_order(order):
	"""
	Updates the Order's shipping cost (if needed).
	"""
	dummy_cart = DummyCart(order.orderitem_set.all())
	
	# Let Satchmo's default shipping calculation method do the heavy work.
	update_shipping(order, order.shipping_model, order.contact, dummy_cart)
Esempio n. 3
0
    def is_needed(self):
        """Check to see if this form is even needed
        it is *not* needed if:
        - we have an order
        - the order balance is zero
        - No shipping needs to be selected
        """
        needed = True
        if self.order and self.tempContact and self.tempCart:
            order = self.order
            if order.is_shippable and len(self.shipping_dict) == 1:
                update_shipping(order, list(self.shipping_dict.keys())[0], self.tempContact, self.tempCart)
            order.recalculate_total(save=False)
            needed = not order.paid_in_full
            if not needed:
                log.debug('%s can skip the payment step - no info needed', order)

        return needed
Esempio n. 4
0
    def is_needed(self):
        """Check to see if this form is even needed
        it is *not* needed if:
        - we have an order
        - the order balance is zero
        - No shipping needs to be selected
        """

        needed = True
        if self.order and self.tempContact and self.tempCart:
            order = self.order
            if order.is_shippable and len(self.shipping_dict) == 1:
                update_shipping(order, self.shipping_dict.keys()[0], self.tempContact, self.tempCart)
            order.recalculate_total(save=False)
            needed = not order.paid_in_full
            if not needed:
                log.debug('%s can skip the payment step - no info needed', order)

        return needed
Esempio n. 5
0
def pay_ship_save(new_order, cart, contact, shipping, discount, update=False):
    """
    Save the order details, first removing all items if this is an update.
    """
    update_shipping(new_order, shipping, contact, cart)

    if not update:
        # Temp setting of the tax and total so we can save it
        new_order.total = Decimal('0.00')
        new_order.tax = Decimal('0.00')
        new_order.sub_total = cart.total
        new_order.method = 'Online'

    if discount:
        new_order.discount_code = discount
    else:
        new_order.discount_code = ""

    update_orderitems(new_order, cart, update=update)