Commit 64d7d599 authored by Rafael Monnerat's avatar Rafael Monnerat Committed by Xiaowu Zhang

Included script for one-click-order

parent 4fd98a90
......@@ -105,13 +105,16 @@ for order_line in shopping_cart_items:\n
if order_line.getResource() == resource.getRelativeUrl():\n
if (not variation or order_line.getVariation() == variation)\\\n
and (not size or order_line.getSize() == size):\n
line_found = True\n
if checkout:\n
# We don\'t update quantities if it is a direct checkout.\n
break\n
new_quantity = int(order_line.getQuantity()) + quantity\n
if new_quantity <= 0:\n
## remove items with zero quantity\n
shopping_cart.manage_delObjects(order_line)\n
else:\n
order_line.setQuantity(new_quantity)\n
line_found=True\n
break\n
\n
if not line_found:\n
......@@ -123,6 +126,12 @@ if not line_found:\n
if size: order_line.setSize(size)\n
order_line.setPrice(context.getPrice(supply_path_type=["Sale Supply Line", "Sale Supply Cell"], context=order_line))\n
\n
if checkout:\n
website = context.getWebSiteValue()\n
if website is not None:\n
return website.cart.Base_redirect("", \n
keep_items={\'portal_status_message\':context.Base_translateString("Added to cart.")})\n
\n
if( context.getPortalType() == \'Product\'):\n
context.Base_redirect(\'Resource_viewAsShop\',\n
keep_items={\'portal_status_message\':context.Base_translateString("Added to cart."),\n
......@@ -137,7 +146,7 @@ else:\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>resource=None, quantity=1, form_id=None</string> </value>
<value> <string>resource=None, quantity=1, form_id=None, checkout=False</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>return context.Resource_addToShoppingCart(resource=resource, \n
quantity=quantity, \n
form_id=form_id, \n
checkout=True)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>resource=None, quantity=1, form_id=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Resource_checkout</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Add resource to shopping cart</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
316
\ No newline at end of file
317
\ No newline at end of file
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