def is_incremental_update(self, product_code, quantity): cart = get_cart() item_id = product_code if item_id in cart: cart[item_id] = quantity return cart[item_id] return None
def update(self): context = aq_inner(self.context) here_url = context.absolute_url() cart = get_cart() order_id = self.request.get('oid', '') txn_id = cart['txn_id'] if self.is_equal(order_id, txn_id): self.next_url = here_url + '/@@order-confirmation?txnid=' + txn_id wipe_cart()
def add(self, item_uuid, quantity=1): """ Add item to shopping cart """ cart = get_cart() qty = int(quantity) item = self.is_incremental_update(item_uuid, qty) if not item: cart[item_uuid] = qty return cart[item_uuid]
def cart(self): cart = get_cart() data = [] for item in cart: info = {} product = uuidToObject(item) quantity = cart[item] info['uuid'] = item info['quantity'] = quantity info['title'] = product.Title() info['description'] = product.Description() info['image_tag'] = self.image_tag(product) info['url'] = product.absolute_url() info['price'] = product.price info['shipping'] = product.shipping_price info['price_pretty'] = format_price(product.price) total = int(quantity) * product.price info['price_total'] = format_price(total) data.append(info) return data
def has_cart(self): cart = get_cart() return len(cart) > 0
def has_cart(self): cart = get_cart() if 'txn_id' in cart: return False return len(cart) > 0
def cart(self): cart = get_cart() if "txn_id" in cart: return "" else: return cart
def mark(self, txn_id): """ Mark cart when initializing transactions """ cart = get_cart() cart['txn_id'] = txn_id return txn_id
def delete(self, item_uuid): """ Remove item from shopping cart """ cart = get_cart() if item_uuid in cart: del cart[item_uuid] return item_uuid