def getProductPrice(product_id): product_price = mongoProductPrice.find_one({'product_id': product_id}) try: priceList = product_price['priceList'] except: priceList = [] min_priceDict = {} override_Price = mongoProductOverridePrice.find_one( {'product_id': product_id}) if priceList: min_price = 100000000 for price in priceList: if override_Price: override_Price_Dict = override_Price['override_price'] override_website_price = None try: override_website_price = override_Price_Dict[ price['website']] except: override_website_price = None if override_website_price: price['price'] = override_website_price if price['price'] < min_price and price['price'] != 0: min_price = price['price'] min_priceDict = price return product_price, min_priceDict
def priceOverride(product_id): if request.method == 'GET': return render_template('admin/priceOverride.html', product_id=product_id) if request.method == 'PUT': productDoc = {} respData = json.loads(request.data) if respData['override_price']: productDoc['product_id'] = product_id productDoc['override_price'] = respData['override_price'] document = mongoProductOverridePrice.find_one({'product_id':product_id}) if document: productDoc["_id"] = document["_id"] mongoProductOverridePrice.save(productDoc) else: mongoProductOverridePrice.insert(productDoc) return "Listing form submitted successfully"
def priceOverride(product_id): if request.method == 'GET': return render_template('admin/priceOverride.html', product_id=product_id) if request.method == 'PUT': productDoc = {} respData = json.loads(request.data) if respData['override_price']: productDoc['product_id'] = product_id productDoc['override_price'] = respData['override_price'] document = mongoProductOverridePrice.find_one( {'product_id': product_id}) if document: productDoc["_id"] = document["_id"] mongoProductOverridePrice.save(productDoc) else: mongoProductOverridePrice.insert(productDoc) return "Listing form submitted successfully"