Chris McDonough:
> weeping (although grateful for the exchange),

I'm sorry Chris.  We didn't give you a very good debugging chase.  I
know how frustrating bug reports like "Help! It doesn't work" is, but I
guess it's very hard to troubleshoot bugs in frameworks since there's so
much customized code in there.

To be a little bit more helpful I've included two functions:

cart_add(sku, qty) (Python Script)
        This function adds qty amount of a skus (integer id for product
items) to the cart

cart_display (DTML Method)
        This method displayes the cart

The bug appears even when these two functions are the only functions
interacting with the session and the shopping.  There are obviously some
references to code not provided in there, so don't expect them to work
just like that.  If you can't see anything wrong from a simple code
inspection, I volounteer to provide the whole site for you.

It's quite refreshing to do a project for a sandwich shop, like we do
now, but I hope we can get to the bottom of these disappearing cokes. :)

Thank you for all the help.  Open source sure beats the heck out of
commercial solutions when it comes to support.

Bjorn Stabell <[EMAIL PROTECTED]>

cart_add(sku, qty)

session = context.session_mgr.getSessionData()

cart = session.get('shopping_cart', {})

sku = int(sku)

if not cart.has_key(sku):
  cart[sku] = 0

if int(qty)>0: 
   cart[sku] = cart[sku] + int(qty)

session.set('shopping_cart', cart)




<dtml-call "REQUEST.set('totalprice',0)">
Session token key, value: <dtml-var "session_mgr.getTokenKey()">,
<dtml-var "session_mgr.getToken()"><br>

<dtml-let cart="session_mgr.getSessionData().get('shopping_cart', {})">

<dtml-if "cart.keys()">

<dtml-in "cart.keys()" sort>
 <dtml-if sequence-start>
  <table border="0" cellspacing="0" cellpadding="0" width="100%">
    <td bgcolor="#FFDAAB"> 
     <form action="cart_change" method="post">
      <table width="100%" border="0" cellspacing="1" cellpadding="2"
        <td colspan="2" bgcolor="#006633" class="pagetitle"><dtml-var
"gettext('Order Bag')"></td>
        <td><dtml-var "gettext('Category')"></td>
        <td align="right" width="20%"><dtml-var "gettext('Qty')"></td>
  </dtml-if sequence-start>               

  <dtml-let shop_item="get_shop_item(_['sequence-item'])">
   <tr valign="top"> 
    <td bgcolor="#FFFFFF">
    <!--dtml-var "shop_item.Description()"--> 
    <dtml-var "shop_item.Title()">
    <a href="cart_rm?sku=&dtml-sequence-item;"><dtml-var
     <!--dtml-var "shop_item.absolute_url()" html_quote-->
    <a href="cart_rm?sku=&dtml-sequence-item;">remove</a>
    <!--dtml-var "shop_item.price">
    <dtml-let qty="[_['sequence-item']])">
    <dtml-call "REQUEST.set('totalprice', totalprice + shop_item.price *
    <td nowrap bgcolor="#FFFFFF"><input type="hidden" name="skus:list"
    <input type="text" name="sku_&dtml-sequence-item;:int"
value="<dtml-var "cart[_['sequence-item']]">" size="1">
   <dtml-if sequence-end>      
     <tr valign="top"> 
     <td colspan="2" align="right" class="RMB"
bgcolor="#FFFFCC"><dtml-var "gettext('TOTAL')"> 
"'shopping_cart_amount', 0))">
     <tr valign="top"> 
     <td colspan="2" bgcolor="#FFFFFF">
<b><dtml-var "gettext('Bonus points')"></b> <br>
<dtml-var "gettext('This order is worth')"> <dtml-var
"'shopping_cart_bonus', 0))">
       <dtml-unless "portal_membership.isAnonymousUser()">
                        <dtml-var "gettext('Bonus points to spend')">
<dtml-var "">
     <tr valign="top"> 
      <td colspan="2" bgcolor="#FFFFFF"> 
       <input type="submit" name="Submit" value="<dtml-var
       <a href="orderForm"><dtml-var "gettext('Checkout')"></a> </td>
   </table></dtml-if sequence-end>



Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to