def update_orderitem_details(new_order_item, item): """Update orderitem details, if any. """ if item.has_details: # Check to see if cartitem has CartItemDetails # If so, add here. #obj = CustomTextField.objects.get(id=item.details.values()[0]['customfield_id']) #val = item.details.values()[0]['detail'] for detail in item.details.all(): new_details = OrderItemDetail(item=new_order_item, value=detail.value, name=detail.name, price_change=detail.price_change, sort_order=detail.sort_order) new_details.save()
def make_test_order(country, state): c = Contact(first_name="Gift", last_name="Tester", role=ContactRole.objects.get(pk='Customer'), email="*****@*****.**") c.save() if not isinstance(country, Country): country = Country.objects.get(iso2_code__iexact = country) ad = AddressBook(contact=c, description="home", street1 = "test", state=state, city="Portland", country = country, is_default_shipping=True, is_default_billing=True) ad.save() site = Site.objects.get_current() o = Order(contact=c, shipping_cost=Decimal('0.00'), site=site) o.save() p = Product.objects.get(slug='GIFT10') price = p.unit_price log.debug("creating with price: %s", price) item1 = OrderItem(order=o, product=p, quantity='2.0', unit_price=price, line_item_price=price*2) item1.save() detl = OrderItemDetail(name = 'email', value='*****@*****.**', sort_order=0, item=item1) detl.save() detl = OrderItemDetail(name = 'message', value='hello there', sort_order=0, item=item1) detl.save() return o
def make_test_order(country, state): c = Contact(first_name="Gift", last_name="Tester", role=ContactRole.objects.get(pk='Customer'), email="*****@*****.**") c.save() if not isinstance(country, Country): country = Country.objects.get(iso2_code__iexact=country) ad = AddressBook(contact=c, description="home", street1="test", state=state, city="Portland", country=country, is_default_shipping=True, is_default_billing=True) ad.save() site = Site.objects.get_current() o = Order(contact=c, shipping_cost=Decimal('0.00'), site=site) o.save() p = Product.objects.get(slug='GIFT10') price = p.unit_price log.debug("creating with price: %s", price) item1 = OrderItem(order=o, product=p, quantity='2.0', unit_price=price, line_item_price=price * 2) item1.save() detl = OrderItemDetail(name='email', value='*****@*****.**', sort_order=0, item=item1) detl.save() detl = OrderItemDetail(name='message', value='hello there', sort_order=0, item=item1) detl.save() return o