Logo Search packages:      
Sourcecode: zope-emarket version File versions

def EMarket::ShopperManager::ShopperManager::addToBasket (   self,
  REQUEST = None,
  RESPONSE = None 
)

Add and item to the basket... get everything from the 'REQUEST'

returns  statusMsg, statusCode

where

    statusMsg = "OK" if all is well and offer is high enough
        "Failed" if there is some unrecoverable problem

    statusCode =
       -1 cannot find any MarketItem to match request
       1  attempt to drop quantity
       2  not enough product remaining
       3  attempt to drop offer
       4  offer is below minPrice, or it's an auction

Definition at line 79 of file ShopperManager.py.

00079                                                       :

        """ Add and item to the basket... get everything from the 'REQUEST'

        returns  statusMsg, statusCode

        where

            statusMsg = "OK" if all is well and offer is high enough
                        "Failed" if there is some unrecoverable problem

            statusCode =
                       -1 cannot find any MarketItem to match request
                       1  attempt to drop quantity
                       2  not enough product remaining
                       3  attempt to drop offer
                       4  offer is below minPrice, or it's an auction
        """
        # py-mode can be wierd sometimes...
        #
    
        itemID = REQUEST.get('itemID',None)
        quantity = REQUEST.get('quantity',0)
        updateBasket = REQUEST.get('updateBasket',0)
        shopperId = REQUEST.get('clientCookie')
        basketId = self.currentBasketId( shopperId )

        if type(quantity) == type(''):
            quantity = string.strip(quantity)
            quantity = string.replace(quantity,',','')
            quantity = int(string.atoi(quantity))

        optionDict={}

        if REQUEST.has_key('optionDict'):
            optionDict = REQUEST['optionDict']

        elif REQUEST.has_key('options'):
            options = string.split(string.strip(REQUEST['options'])[1:-1],',')
            for option in options:
                option = string.strip(option)[1:-1]  # get rid of quotes!
                optionDict[option] = REQUEST.get(option,'')
        
        item = self.marketFolder.getItem(itemID)

        if item is not None: # we found the item....
            if quantity > 0:
                self.basketManager.addItemToBasket( shopperId, item, quantity, updateBasket, REQUEST )
            else:
                self.basketManager.deleteItemFromBasket( theItem=item, basketId=basketId, REQUEST=REQUEST )

            returnVal = "OK",0
        else:
            returnVal="Failed",-1

        return returnVal

    def loginAsUser(self, shopperID, REQUEST=None, RESPONSE=None, PARENTS=None, PATH_INFO=None):


Generated by  Doxygen 1.6.0   Back to index