Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
erp5
Commits
0bd9e1cc
Commit
0bd9e1cc
authored
Aug 27, 2012
by
Jean-Paul Smets
Committed by
Xiaowu Zhang
Feb 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement shopping cart with temp portal types
Also improved comments and docstring including TODO.
parent
0cf1daab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
17 deletions
+41
-17
bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/SaleOrder_getShoppingCart.xml
.../portal_skins/erp5_commerce/SaleOrder_getShoppingCart.xml
+41
-17
No files found.
bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/SaleOrder_getShoppingCart.xml
View file @
0bd9e1cc
...
...
@@ -50,8 +50,16 @@
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
""" \n
Add resource to current (or to be created shopping cart). \n
<value>
<string>
"""\n
Create a new shopping cart if needed. Return\n
shopping cart for current customer. Set all local roles\n
permissins so that shopping cart can be modified by anonymous.\n
\n
TODO:\n
- handle reset with another method\n
(more explicit, less risky)\n
- decide whether to keep or remove new_shopping_cart parameter\n
(is it really useful to create a new shopping cart here)\n
"""\n
from DateTime import DateTime\n
\n
...
...
@@ -61,28 +69,44 @@ session_id = request.get(\'session_id\', None)\n
portal_sessions = context.portal_sessions\n
\n
if session_id is None:\n
#
#
first call so generate session_id and send back via cookie\n
# first call so generate session_id and send back via cookie\n
now = DateTime()\n
session_id = context.Base_generateSessionID(max_long=20)\n
request.RESPONSE.setCookie(\'session_id\', session_id, expires=(now +expire_timeout_days).fCommon(), path=\'/\')\n
\n
if action==\'reset\':\n
## reset cart \n
portal_sessions.manage_delObjects(session_id)\n
else:\n
## take shopping cart for this customer\n
shopping_cart_id = \'shopping_cart\'\n
session = portal_sessions[session_id]\n
if not shopping_cart_id in session.keys():\n
from Products.ERP5Type.Document import newTempOrder\n
web_site = context.getWebSiteValue()\n
shopping_cart = newTempOrder(portal_sessions, shopping_cart_id)\n
shopping_cart.setPriceCurrency(web_site.WebSite_getShoppingCartDefaultCurrency().getRelativeUrl())\n
session[shopping_cart_id] = shopping_cart\n
# reset cart and return (a separate method would be better XXX)\n
return portal_sessions.manage_delObjects(session_id)\n
\n
# take shopping cart for this customer\n
shopping_cart_id = \'shopping_cart\'\n
session = portal_sessions[session_id]\n
\n
## return just a part of session for shopping cart\n
# some cleanup could be required if the shopping cart\n
# comes from a previous user with same session\n
if shopping_cart_id in session.keys():\n
shopping_cart = session[shopping_cart_id]\n
return shopping_cart\n
if not shopping_cart.SaleOrder_isShoppingCartConsistent():\n
portal_sessions.manage_delObjects(session_id)\n
session = portal_sessions[session_id]\n
\n
# create shopping cart\n
if not shopping_cart_id in session.keys():\n
from Products.ERP5Type.Document import newTempOrder\n
web_site = context.getWebSiteValue()\n
shopping_cart = context.sale_order_module.newContent(portal_type="Sale Order", id=shopping_cart_id, temp_object=1, container=portal_sessions)\n
# Set usable security for Anonymous\n
shopping_cart.manage_role("Anonymous", ["Access contents information",\n
"Add portal content",\n
"Delete objects",\n
"Modify portal content",\n
"View"])\n
shopping_cart.setPriceCurrency(web_site.WebSite_getShoppingCartDefaultCurrency().getRelativeUrl())\n
session[shopping_cart_id] = shopping_cart\n
\n
## return just a part of session for shopping cart\n
shopping_cart = session[shopping_cart_id]\n
return shopping_cart\n
</string>
</value>
</item>
<item>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment