Commit 4b6572d6 authored by Jean-Paul Smets's avatar Jean-Paul Smets Committed by Xiaowu Zhang

Use shopping cart properties and improve redirect

Also improved comments and docstring including TODO.
parent 0bd9e1cc
......@@ -50,23 +50,30 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string># check if the user is Anonymous, if yes it must be redirected to Registration Dialog\n
<value> <string>"""\n
Redirect to relevant payment mode and force if necessary user\n
to register first.\n
"""\n
# check if the user is Anonymous, if yes he/she must be redirected to Registration Dialog\n
# otherwise it will redirect to the appropriated payment form based on Payment Mode selected\n
request = context.REQUEST\n
isAnon = context.portal_membership.isAnonymousUser()\n
translateString = context.Base_translateString\n
\n
if field_my_comment is not None:\n
shopping_cart = context.SaleOrder_getShoppingCart()\n
shopping_cart.setComment(field_my_comment)\n
shopping_cart = context.SaleOrder_getShoppingCart()\n
field_my_comment = shopping_cart.getComment()\n
field_my_payment_mode = shopping_cart.getPaymentConditionPaymentMode()\n
\n
if isAnon:\n
# create first an account for user\n
web_site = context.getWebSiteValue()\n
msg = translateString("You need to create an account to continue. If you already have please login.")\n
web_site.Base_redirect(\'register\', \\\n
keep_items={\'portal_status_message\': msg})\n
return\n
from ZTUtils import make_query\n
parameter_string = make_query(field_my_comment=field_my_comment, field_my_payment_mode=field_my_payment_mode)\n
coming_from_url = \'%s/SaleOrder_paymentRedirect?%s\' % (context.absolute_url(), parameter_string)\n
return web_site.Base_redirect(\'register\', \\\n
keep_items={\'portal_status_message\': msg,\n
\'coming_from_url\': coming_from_url})\n
\n
if field_my_payment_mode is None:\n
msg = translateString("You must select a payment mode.")\n
......@@ -85,7 +92,7 @@ context.Base_redirect(\'SaleOrder_viewAsWeb\', \\\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>field_my_comment=None, field_my_payment_mode=None, **kw</string> </value>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......@@ -99,6 +106,10 @@ context.Base_redirect(\'SaleOrder_viewAsWeb\', \\\n
<key> <string>id</string> </key>
<value> <string>SaleOrder_paymentRedirect</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Redirect to registration or payment page</string> </value>
</item>
</dictionary>
</pickle>
</record>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment