本文整理汇总了Python中orders.models.Order.shipping方法的典型用法代码示例。如果您正苦于以下问题:Python Order.shipping方法的具体用法?Python Order.shipping怎么用?Python Order.shipping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类orders.models.Order
的用法示例。
在下文中一共展示了Order.shipping方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkout
# 需要导入模块: from orders.models import Order [as 别名]
# 或者: from orders.models.Order import shipping [as 别名]
def checkout(request):
try:
the_cart_id = request.session['cart_id']
cart = Cart.objects.get(id=the_cart_id)
subbies = CartItem.subbie_type.filter(cart=cart)
singles = CartItem.single_type.filter(cart=cart)
cart_items = CartItem.objects.filter(cart=cart)
except:
the_cart_id = None
return HttpResponseRedirect(reverse("view_cart"))
try:
user = request.user
except:
user = None
try:
new_order = Order.objects.get(cart=cart)
except Order.DoesNotExist:
new_order = Order()
new_order.cart = cart
new_order.order_id = id_generator()
new_order.save()
except:
new_order = None
return HttpResponseRedirect(reverse("view_cart"))
if request.user.is_authenticated():
new_order.user = request.user
print new_order.user
print "we gota new order user"
new_order.total = cart.total
new_order.shipping = cart.shipping_total
if new_order.coupon:
coupon = new_order.coupon
percent_discount = coupon.percent_discount
new_total = new_order.total - new_order.total * (float(percent_discount) / 100)
print new_total
new_order.total = new_total
new_order.save()
pay_form = PayForm()
order = new_order
subgo = False
singo = False
paygo = False
usergo = False
if subbies and singles:
for sub in subbies:
if sub.recipient:
subgo = True
else:
subgo = False
if order.main_recipient:
singo = True
else:
singo = False
if subgo == True and singo == True:
paygo = True
else:
paygo = False
elif not subbies and singles:
if order.main_recipient:
singo = True
else:
singo = False
if subgo == False and singo == True:
paygo = True
else:
paygo = False
elif subbies and not singles:
for sub in subbies:
if sub.recipient:
subgo = True
else:
subgo = False
if subgo == True and singo == False:
paygo = True
else:
paygo = False
# check user status
user = request.user
if user.is_authenticated():
usergo = True
elif singles and not subbies:
usergo = True
else:
usergo = False
if request.POST:
#.........这里部分代码省略.........