本文整理汇总了Python中cart.Cart.create_cart方法的典型用法代码示例。如果您正苦于以下问题:Python Cart.create_cart方法的具体用法?Python Cart.create_cart怎么用?Python Cart.create_cart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cart.Cart
的用法示例。
在下文中一共展示了Cart.create_cart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: done
# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import create_cart [as 别名]
def done(self, form_list, **kwargs):
cart = Cart(self.request)
cart.create_cart()
order = Order(cart=cart.cart)
client = form_list[0].save(commit=False)
address = form_list[1].save()
client.shipping_address = address
billing_address = address
if condition_step_3(self):
billing_address = form_list[2].save()
client.billing_address = billing_address
client.save()
order.client = client
payment_option = self.get_cleaned_data_for_step("4").get("payment_options", None)
print ("PAYMENT {0}".format(self.get_cleaned_data_for_step("4")))
language = translation.get_language().upper()
if payment_option == "PayPal":
result = self.create_paypalpayment(cart)
order.payment = result.paypal_payment_db
order.save()
# we need to do the checkout after saving the order,
# if something went wrong
cart.check_out()
mail_result = EMailTemplate.objects.send("{0}_ORDER_SUCCESS_PAYPAL".format(language), client.email,
{"order": order, "billing_address": billing_address,
"shipping_address": address,
"paypal_url": order.payment.approval_url})
if result.payment.error:
logger.error("PayPal payment went wrong! Errors: {0}".format(result.payment.error))
return render(self.request, "cuescience_shop/failure_paypal.html", {"order": order})
elif not result.payment.errors and order.payment.approval_url:
return render(self.request, "cuescience_shop/success_paypal.html", {"order": order})
elif payment_option == "Prepayment":
payment = PrePayment()
payment.save()
order.payment = payment
order.save()
cart.check_out()
mail_result = EMailTemplate.objects.send("{0}_ORDER_SUCCESS_PREPAYMENT".format(language), client.email,
{"order": order, "billing_address": billing_address,
"shipping_address": address})
return render(self.request, "cuescience_shop/success.html", {"order": order})
return render_to_response("cuescience_shop/cart/index.html", RequestContext(self.request))