Example #1
0
    def create_order(self, order_source):
        # order_provision.target_user = self._maybe_create_user(
        #     user=order_provision.target_user,
        #     billing_address=order_provision.billing_address,
        #     shipping_address=order_provision.shipping_address
        # )

        if order_source.billing_address and not order_source.billing_address.pk:
            order_source.billing_address.save()

        if order_source.shipping_address and not order_source.shipping_address.pk:
            order_source.shipping_address.save()

        order = Order(shop=order_source.shop,
                      currency=order_source.currency,
                      prices_include_tax=order_source.prices_include_tax,
                      shipping_method=order_source.shipping_method,
                      payment_method=order_source.payment_method,
                      customer_comment=order_source.customer_comment,
                      marketing_permission=bool(
                          order_source.marketing_permission),
                      ip_address=(self.request.META.get("REMOTE_ADDR")
                                  if self.request else None),
                      creator=real_user_or_none(order_source.creator),
                      orderer=(order_source.orderer or None),
                      customer=(order_source.customer or None),
                      billing_address=order_source.billing_address,
                      shipping_address=order_source.shipping_address,
                      order_date=order_source.order_date,
                      status=order_source.status,
                      payment_data=order_source.payment_data,
                      shipping_data=order_source.shipping_data,
                      extra_data=order_source.extra_data)
        order.save()

        self.process_order_before_lines(source=order_source, order=order)
        lines = self.get_source_order_lines(source=order_source, order=order)
        self.add_lines_into_order(order, lines)

        if any(line.require_verification for line in order.lines.all()):
            order.require_verification = True
            order.all_verified = False
        else:
            order.all_verified = True

        order.cache_prices()
        order.save()

        order_creator_finished.send(OrderCreator,
                                    order=order,
                                    source=order_source,
                                    request=self.request)

        order.save()
        self.process_order_after_lines(source=order_source, order=order)

        # Then do all the caching one more time!
        order.cache_prices()
        order.save()
        return order
Example #2
0
    def create_order(self, order_source):
        # order_provision.target_user = self._maybe_create_user(
        #     user=order_provision.target_user,
        #     billing_address=order_provision.billing_address,
        #     shipping_address=order_provision.shipping_address
        # )

        if order_source.billing_address and not order_source.billing_address.pk:
            order_source.billing_address.save()

        if order_source.shipping_address and not order_source.shipping_address.pk:
            order_source.shipping_address.save()

        order = Order(
            shop=order_source.shop,
            currency=order_source.currency,
            prices_include_tax=order_source.prices_include_tax,
            shipping_method=order_source.shipping_method,
            payment_method=order_source.payment_method,
            customer_comment=order_source.customer_comment,
            marketing_permission=bool(order_source.marketing_permission),
            ip_address=(self.request.META.get("REMOTE_ADDR") if self.request else None),
            creator=real_user_or_none(order_source.creator),
            orderer=(order_source.orderer or None),
            customer=(order_source.customer or None),
            billing_address=order_source.billing_address,
            shipping_address=order_source.shipping_address,
            order_date=order_source.order_date,
            status=order_source.status,
            payment_data=order_source.payment_data,
            shipping_data=order_source.shipping_data,
            extra_data=order_source.extra_data
        )
        order.save()

        self.process_order_before_lines(source=order_source, order=order)
        lines = self.get_source_order_lines(source=order_source, order=order)
        self.add_lines_into_order(order, lines)

        if any(line.require_verification for line in order.lines.all()):
            order.require_verification = True
            order.all_verified = False
        else:
            order.all_verified = True

        order.cache_prices()
        order.save()

        order_creator_finished.send(OrderCreator, order=order, source=order_source, request=self.request)

        order.save()
        self.process_order_after_lines(source=order_source, order=order)

        # Then do all the caching one more time!
        order.cache_prices()
        order.save()
        return order
Example #3
0
    def create_order(self, order_source):
        order = Order(
            shop=order_source.shop,
            currency=order_source.currency,
            prices_include_tax=order_source.prices_include_tax,
            shipping_method=order_source.shipping_method,
            payment_method=order_source.payment_method,
            customer_comment=order_source.customer_comment,
            marketing_permission=bool(order_source.marketing_permission),
            ip_address=order_source.ip_address,
            creator=real_user_or_none(order_source.creator),
            orderer=(order_source.orderer or None),
            customer=(order_source.customer or None),
            billing_address=(order_source.billing_address.to_immutable()
                             if order_source.billing_address else None),
            shipping_address=(order_source.shipping_address.to_immutable()
                              if order_source.shipping_address else None),
            order_date=order_source.order_date,
            status=order_source.status,
            payment_data=order_source.payment_data,
            shipping_data=order_source.shipping_data,
            extra_data=order_source.extra_data)
        order.save()

        self.process_order_before_lines(source=order_source, order=order)
        lines = self.get_source_order_lines(source=order_source, order=order)
        self.add_lines_into_order(order, lines)

        if any(line.require_verification for line in order.lines.all()):
            order.require_verification = True
            order.all_verified = False
        else:
            order.all_verified = True

        order.cache_prices()
        order.save()

        if order.customer and order.customer.marketing_permission != order.marketing_permission:
            order.customer.marketing_permission = order.marketing_permission
            order.customer.save(update_fields=["marketing_permission"])

        self._assign_code_usages(order_source, order)

        order_creator_finished.send(sender=type(self),
                                    order=order,
                                    source=order_source)

        order.save()
        self.process_order_after_lines(source=order_source, order=order)

        # Then do all the caching one more time!
        order.cache_prices()
        order.save()
        return order
Example #4
0
    def create_order(self, order_source):
        order = Order(
            shop=order_source.shop,
            currency=order_source.currency,
            prices_include_tax=order_source.prices_include_tax,
            shipping_method=order_source.shipping_method,
            payment_method=order_source.payment_method,
            customer_comment=order_source.customer_comment,
            marketing_permission=bool(order_source.marketing_permission),
            ip_address=order_source.ip_address,
            creator=real_user_or_none(order_source.creator),
            orderer=(order_source.orderer or None),
            customer=(order_source.customer or None),
            billing_address=(order_source.billing_address.to_immutable() if order_source.billing_address else None),
            shipping_address=(order_source.shipping_address.to_immutable() if order_source.shipping_address else None),
            order_date=order_source.order_date,
            status=order_source.status,
            payment_data=order_source.payment_data,
            shipping_data=order_source.shipping_data,
            extra_data=order_source.extra_data
        )
        order.save()

        self.process_order_before_lines(source=order_source, order=order)
        lines = self.get_source_order_lines(source=order_source, order=order)
        self.add_lines_into_order(order, lines)

        if any(line.require_verification for line in order.lines.all()):
            order.require_verification = True
            order.all_verified = False
        else:
            order.all_verified = True

        order.cache_prices()
        order.save()

        if order.customer and order.customer.marketing_permission != order.marketing_permission:
            order.customer.marketing_permission = order.marketing_permission
            order.customer.save(update_fields=["marketing_permission"])

        self._assign_code_usages(order_source, order)

        order_creator_finished.send(
            sender=type(self), order=order, source=order_source)

        order.save()
        self.process_order_after_lines(source=order_source, order=order)

        # Then do all the caching one more time!
        order.cache_prices()
        order.save()
        return order