Passing Stripe Fee to Customer: Unaccounted Profit with Formula Usage - javascript

Referring to when you pass the Stripe fee to your customer by offsetting the final total charge to them using the given formula.
Considering the following scenario for a Payment Intent:
Buyer is purchasing a $1,000.00 item (Pgoal)
Buyer is charged Australian Stripe fees of 1.75% on the item (Fpercent)
Buyer is charged a fixed fee of $0.30 AUD (Ffixed)
Buyer is charged a 10% tax only on the Stripe fees component (Ftax, i.e. 10% of whatever is 1.75% of the amount + 30c fixed)
When I check Stripe Dashboard for this Payment Intent using the formula prescribed by Stripe, the following is calculated:
Amount: A$1,019.92
Fee: A$18.15
Stripe Processing Fees: A$16.50
Tax: A$1.65
Net: A$1,001.77
The problem is why am I profiting $1.77?? It should be $1,000.00 flat. Not sure what I'm doing wrong, so any help is appreciated.
The formula Stripe provides is pretty straight forward:
Pcharge = ( Pgoal + Ffixed )
------------------
( 1 - Fpercent )
- Pgoal is $1,000.00 or 100000 (in cents)
- Ffixed is 0.30 or 30 (in cents)
- Fpercent is 1.75% or 0.0175
The only issue with above formula is that it doesn't account for Stripe's taxes it charges the Buyer, which in Australia is 10% on the total Stripe fees. So I've gone ahead and accounted for it in the numerator of the formula:
Pcharge = ( Pgoal + Ffixed + Ftax )
-------------------------
( 1 - Fpercent )
- Pgoal is $1,000.00 or 100000 (in cents)
- Ffixed is 0.30 or 30 (in cents)
- Fpercent is 1.75% or 0.0175
- Ftax is 10% on the Stripe fees, or [ 0.1 * ( Pgoal * Fpercent + Ffixed ) ]

Related

Ruby script to calculate discount using Shopify Scripts

I am using a script to calculate an addtional 5% off when the cart total is greater than $1000, but the variant price is already discounted by 25% and has a was/now pricing setup that is $29.95 was $39.95.
The problem is - i need for the script to discount the orginal item value of $39.95, not the discounted rate which is the new retail price.
Here is the script - i have tried to add 25% back to the line item price without success and there is no line item method that Shopify provides to use the orginal cart line item price in the dev docs - https://help.shopify.com/en/manual/checkout-settings/script-editor/shopify-scripts#line-item-methods
# Tiered Discounts by Spend Threshold 5% off when you spend $1000 or more
min_discount_order_amount_extra = Money.new(cents:100) * 1000 #number of dollars needed in cart to get the discount
DISCOUNT_PERCENT = 25
# calculate the discount to be applied
percent = Decimal.new(DISCOUNT_PERCENT/100) + 1
total = Input.cart.subtotal_price_was * percent
discount = if total > min_discount_order_amount_extra
0.05 #discount percentage in decimal form
else
0
end
message = "Another 5% saved"
# 30% off products excluding commercial items
Input.cart.line_items.each do |line_item|
product = line_item.variant.product
next if product.gift_card?
next if line_item.variant.product.tags.any?{|x| ['commercial'].include?(x)};
line_item.change_line_price(line_item.line_price * (1-discount), message: message) unless discount == 0
end
Output.cart = Input.cart

Subject of Email Should changed based on Cell Value

I have created a Google script to send an email once the user submits the form. The script is running very well. But one thing that is not proper is the subject of the email. I want the email subject to be changed based on the cell value.
Currently, I am using this script:
function afterFormSubmit(e) {
const info = e.namedValues;
const pdfFile = createPDF(info);
const entryRow = e.range.getRow();
const ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Final Responses");
ws.getRange(entryRow, 64).setValue(pdfFile.getUrl());
ws.getRange(entryRow, 65).setValue(pdfFile.getName());
sendEmail(e.namedValues ['Email address'][0],pdfFile);
}
function sendEmail(email,pdfFile){
var DOR = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Final Responses").getActiveCell();
var NOO = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Final Responses").getActiveCell();
var subject = "DTR - KCCO - " + NOO + " - " + DOR;
var body = "Sir," + String.fromCharCode(10)+ String.fromCharCode(10) + "Please find the attached Daily Transaction Report for the outlet " + NOO + " for " + DOR + "." + String.fromCharCode(10) + String.fromCharCode(10)+ "--" + String.fromCharCode(10) + "Thanks & Regards" + String.fromCharCode(10) + "KCCO - Automation Team" ;
GmailApp.sendEmail(email, subject, body, {
attachments: [pdfFile],
name: 'KCCO - Automation Team'
});
}
function createPDF(info) {
const pdfFolder = DriveApp.getFolderById("1ME3EqHOZzBZDBLNPHQxLjf5tWiQpmE8u");
const tempFolder = DriveApp.getFolderById("1ebglel6vwMGXByeG4wHBBvJu9u0zJeMJ");
const templateDoc = DriveApp.getFileById("1kyFimRMdHQZV85F5P6JyCHv1DQ3KJFv1hx5o7lIcNZo");
const newTempFile = templateDoc.makeCopy(tempFolder);
const openDoc = DocumentApp.openById(newTempFile.getId());
const body = openDoc.getBody();
body.replaceText("{Name of Person}", info['Name of Person'][0]);
body.replaceText("{Date of Report}", info['Date of Report'][0]);
body.replaceText("{Name of Outlet}", info['Name of Outlet'][0]);
body.replaceText("{Opening Petty Cash Balance}", info['Opening Petty Cash Balance'][0]);
body.replaceText("{Total Petty Cash Received}", info['Total Petty Cash Received'][0]);
body.replaceText("{Closing Petty Cash Balance}", info['Closing Petty Cash Balance'][0]);
body.replaceText("{Total Petty Cash Paid}", info['Total Petty Cash Paid'][0]);
body.replaceText("{Available Float Cash Balance}", info['Available Float Cash Balance'][0]);
body.replaceText("{Milk for Outlet}", info['Milk for Outlet'][0]);
body.replaceText("{Cold Drink And Ice Cube Purchased}", info['Cold Drink And Ice Cube Purchased'][0]);
body.replaceText("{Goods Purchased for Outlet}", info['Goods Purchased for Outlet'][0]);
body.replaceText("{Staff Milk/Toast etc.}", info['Staff Milk/Toast etc.'][0]);
body.replaceText("{Water Tank Charges}", info['Water Tank Charges'][0]);
body.replaceText("{Repair And Maintenance}", info['Repair And Maintenance'][0]);
body.replaceText("{Petrol Expenses}", info['Petrol Expenses'][0]);
body.replaceText("{Freight Paid}", info['Freight Paid'][0]);
body.replaceText("{Purchase of Soya Chaap}", info['Purchase of Soya Chaap'][0]);
body.replaceText("{Purchase of Rumali Roti}", info['Purchase of Rumali Roti'][0]);
body.replaceText("{Purchase of Egg Tray}", info['Purchase of Egg Tray'][0]);
body.replaceText("{Other Expenses}", info['Other Expenses'][0]);
body.replaceText("{Please Specify Other Expenses}", info['Please Specify Other Expenses'][0]);
body.replaceText("{Total Tip Amount PAYTM & CARD}", info['Total Tip Amount PAYTM & CARD'][0]);
body.replaceText("{Cash Sales - Outlet}", info['Cash Sales - Outlet'][0]);
body.replaceText("{Cash Sales - KCCO App}", info['Cash Sales - KCCO App'][0]);
body.replaceText("{Card Sales}", info['Card Sales'][0]);
body.replaceText("{Credit/Udhar Sales}", info['Credit/Udhar Sales'][0]);
body.replaceText("{Paytm Sales}", info['Paytm Sales'][0]);
body.replaceText("{KCCO App Sales Razor Pay}", info['KCCO App Sales Razor Pay'][0]);
body.replaceText("{Swiggy Sales}", info['Swiggy Sales'][0]);
body.replaceText("{Zomato Sales}", info['Zomato Sales'][0]);
body.replaceText("{Dunzo Sales}", info['Dunzo Sales'][0]);
body.replaceText("{Zomato Gold Sales}", info['Zomato Gold Sales'][0]);
body.replaceText("{Dine Out Sales}", info['Dine Out Sales'][0]);
body.replaceText("{Total Cancelled Bill Amount}", info['Total Cancelled Bill Amount'][0]);
body.replaceText("{Total Sales of the Day - Total of Above}", info['Total Sales of the Day - Total of Above'][0]);
body.replaceText("{Total Sales of the Day - As Per PetPooja}", info['Total Sales of the Day - As Per PetPooja'][0]);
body.replaceText("{Old Due Receipts - Cash}", info['Old Due Receipts - Cash'][0]);
body.replaceText("{Old Due Receipts - Other Modes}", info['Old Due Receipts - Other Modes'][0]);
body.replaceText("{Tip Receipts - Card}", info['Tip Receipts - Card'][0]);
body.replaceText("{Tip Receipts - Paytm}", info['Tip Receipts - Paytm'][0]);
body.replaceText("{Currency Note of INR 2000}", info['Currency Note of INR 2000'][0]);
body.replaceText("{Currency Note of INR 500}", info['Currency Note of INR 500'][0]);
body.replaceText("{Currency Note of INR 200}", info['Currency Note of INR 200'][0]);
body.replaceText("{Currency Note of INR 100}", info['Currency Note of INR 100'][0]);
body.replaceText("{Currency Note of INR 50}", info['Currency Note of INR 50'][0]);
body.replaceText("{Currency Note of INR 20}", info['Currency Note of INR 20'][0]);
body.replaceText("{Currency Note of INR 10}", info['Currency Note of INR 10'][0]);
body.replaceText("{Other Currency Note/Coins}", info['Other Currency Note/Coins'][0]);
body.replaceText("{Total Available Cash to Handover}", info['Total Available Cash to Handover'][0]);
body.replaceText("{Total No. of Credit Bills}", info['Total No. of Credit Bills'][0]);
body.replaceText("{S.No.//Name of Person// Mobile No// Credit Approval By// Bill No// Total Amount of Credit}", info['S.No.//Name of Person// Mobile No// Credit Approval By// Bill No// Total Amount of Credit'][0]);
body.replaceText("{Total No. of Bills of Credit Recovery}", info['Total No. of Bills of Credit Recovery'][0]);
body.replaceText("{S.No.//Name of Person// Mobile No// Mode of Payment// Bill No// Total Amount Received}", info['S.No.//Name of Person// Mobile No// Mode of Payment// Bill No// Total Amount Received'][0]);
body.replaceText("{Total No. of Complementary Bills During the Day}", info['Total No. of Complementary Bills During the Day'][0]);
body.replaceText("{S.No.//Name of Person// Mobile No//Reason// Bill No//Amount Settled}", info['S.No.//Name of Person// Mobile No//Reason// Bill No//Amount Settled'][0]);
body.replaceText("{Total No. of Cancelled Bills During the Day}", info['Total No. of Cancelled Bills During the Day'][0]);
body.replaceText("{S.No.//Name of Person// Mobile No// Bill No// Bill Amount}", info['S.No.//Name of Person// Mobile No// Bill No// Bill Amount'][0]);
body.replaceText("{S.No.// Bill No// Mode of Payment//Tip Amount Received}", info['S.No.// Bill No// Mode of Payment//Tip Amount Received'][0]);
body.replaceText("{No. of Cylinders Received at Outlet}", info['No. of Cylinders Received at Outlet'][0]);
body.replaceText("{Timestamp}", info['Timestamp'][0]);
body.replaceText("{Email address}", info['Email address'][0]);
//body.replaceText("{Total of Cash Denomination}", info['Total of Cash Denomination'][0]);
openDoc.saveAndClose();
const blobPDF = newTempFile.getAs(MimeType.PDF);
const pdfFile = pdfFolder.createFile(blobPDF).setName('DTR - KCCO - '+info['Name of Outlet'][0]+ " - " + info['Date of Report'][0]);
tempFolder.removeFile(newTempFile);
return pdfFile;
}
The link of the Response submitted by a Google form is as below:
https://docs.google.com/spreadsheets/d/1m6Aca0TcLf5UZ7P9CvAdQDokoazQljsqDT6CGh0K3j4/edit?usp=sharing
I want the Name of the Outlet i.e. F2:F
and Date of Report i.e. C2:C
E.g. if the user submits the form now data will appear in the 37th row so the name of the outlet and report should be F37 and C37.
Please guide.

Generation of PDF from Google Form using Doc template using Script

I am using this script to create PDF from Google from using template in Google Docs.
The script I am using is as below:
function afterFormSubmit(e) {
const info = e.namedValues;
const pdfFile = createPDF(info);
const entryRow = e.range.getRow();
const ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2")
ws.getRange(entryRow, 63).setValue(pdfFile.getUrl());
ws.getRange(entryRow, 64).setValue(pdfFile.getName());
sendEmail(e.namedValues ['Email address'][0],pdfFile);
}
function sendEmail(email,pdfFile){
GmailApp.sendEmail(email, "Daily Transation Summary Report", "Please find the attached DTR", {
attachments : [pdfFile],
name: 'My Company'
});
}
function createPDF(info) {
const pdfFolder = DriveApp.getFolderById("1ebglel6vwMGXByeG4wHBBvJu9u0zJeMJ");
const tempFolder = DriveApp.getFolderById("1ebglel6vwMGXByeG4wHBBvJu9u0zJeMJ");
const templateDoc = DriveApp.getFileById("1kyFimRMdHQZV85F5P6JyCHv1DQ3KJFv1hx5o7lIcNZo");
const newTempFile = templateDoc.makeCopy(tempFolder);
const openDoc = DocumentApp.openById(newTempFile.getId());
const body = openDoc.getBody();
body.replaceText("{Name of Person}", info['Name of Person'][0]);
body.replaceText("{Date of Report}", info['Date of Report'][0]);
body.replaceText("{Name of Outlet}", info['Name of Outlet'][0]);
body.replaceText("{Opening Petty Cash Balance}", info['Opening Petty Cash Balance'][0]);
body.replaceText("{Total Petty Cash Received}", info['Total Petty Cash Received'][0]);
body.replaceText("{Closing Petty Cash Balance}", info['Closing Petty Cash Balance'][0]);
body.replaceText("{Total Petty Cash Paid}", info['Total Petty Cash Paid'][0]);
body.replaceText("{Available Float Cash Balance}", info['Available Float Cash Balance'][0]);
body.replaceText("{Milk For Outlet}", info['Milk For Outlet'][0]);
body.replaceText("{Staff Milk/Toast etc.}", info['Staff Milk/Toast etc.'][0]);
body.replaceText("{Petrol Expenses}", info['Petrol Expenses'][0]);
body.replaceText("{Water Tank Charges}", info['Water Tank Charges'][0]);
body.replaceText("{Repair And Maintenance}", info['Repair And Maintenance'][0]);
body.replaceText("{Freight Paid}", info['Freight Paid'][0]);
body.replaceText("{Purchase of Soya Chaap}", info['Purchase of Soya Chaap'][0]);
body.replaceText("{Purchase of Rumali Roti}", info['Purchase of Rumali Roti'][0]);
body.replaceText("{Purchase of Egg Tray}", info['Purchase of Egg Tray'][0]);
body.replaceText("{Other Expenses}", info['Other Expenses'][0]);
body.replaceText("{Total Tip Amount (PAYTM & CARD)}", info['Total Tip Amount (PAYTM & CARD)'][0]);
body.replaceText("{Cash Sales - Outlet}", info['Cash Sales - Outlet'][0]);
body.replaceText("{Cash Sales - KCCO App}", info['Cash Sales - KCCO App'][0]);
body.replaceText("{Card Sales}", info['Card Sales'][0]);
body.replaceText("{Credit (Udhar) Sales}", info['Credit (Udhar) Sales'][0]);
body.replaceText("{Paytm Sales}", info['Paytm Sales'][0]);
body.replaceText("{KCCO App Sales Razor Pay}", info['KCCO App Sales Razor Pay'][0]);
body.replaceText("{Swiggy Sales}", info['Swiggy Sales'][0]);
body.replaceText("{Zomato Sales}", info['Zomato Sales'][0]);
body.replaceText("{Dunzo Sales}", info['Dunzo Sales'][0]);
body.replaceText("{Zomato Gold Sales}", info['Zomato Gold Sales'][0]);
body.replaceText("{Dine Out Sales}", info['Dine Out Sales'][0]);
body.replaceText("{Total Cancelled Bill Amount}", info['Total Cancelled Bill Amount'][0]);
body.replaceText("{Total Sales of the Day (Total of Above)}", info['Total Sales of the Day (Total of Above)'][0]);
body.replaceText("{Total Sales of the Day (As Per PetPooja)}", info['Total Sales of the Day (As Per PetPooja)'][0]);
body.replaceText("{Old Due Receipts - Cash}", info['Old Due Receipts - Cash'][0]);
body.replaceText("{Old Due Receipts - Other Modes}", info['Old Due Receipts - Other Modes'][0]);
body.replaceText("{Tip Receipts - Card}", info['Tip Receipts - Card'][0]);
body.replaceText("{Tip Receipts - Paytm}", info['Tip Receipts - Paytm'][0]);
body.replaceText("{Currency Note of INR 2000}", info['Currency Note of INR 2000'][0]);
body.replaceText("{Currency Note of INR 500}", info['Currency Note of INR 500'][0]);
body.replaceText("{ Currency Note of INR 200}", info[' Currency Note of INR 200'][0]);
body.replaceText("{Currency Note of INR 100}", info['Currency Note of INR 100'][0]);
body.replaceText("{Currency Note of INR 50}", info['Currency Note of INR 50'][0]);
body.replaceText("{Currency Note of INR 20}", info['Currency Note of INR 20'][0]);
body.replaceText("{Currency Note of INR 10}", info['Currency Note of INR 10'][0]);
body.replaceText("{Other Currency Note/Coins}", info['Other Currency Note/Coins'][0]);
body.replaceText("{Total Available Cash to Handover}", info['Total Available Cash to Handover'][0]);
body.replaceText("{S.No.//Name of Person// Mobile No// Credit Approval By// Bill No// Total Amount of Credit", info['S.No.//Name of Person// Mobile No// Credit Approval By// Bill No// Total Amount of Credit'][0]);
body.replaceText("{Total No. of Bills of Credit Recovery}", info['Total No. of Bills of Credit Recovery'][0]);
body.replaceText("{S.No.//Name of Person// Mobile No// Mode of Payment// Bill No// Total Amount Received}", info['S.No.//Name of Person// Mobile No// Mode of Payment// Bill No// Total Amount Received'][0]);
body.replaceText("{Total No. of Complementary Bills During the Day}", info['Total No. of Complementary Bills During the Day'][0]);
body.replaceText("{S.No.//Name of Person// Mobile No//Reason// Bill No//Amount Settled}", info['S.No.//Name of Person// Mobile No//Reason// Bill No//Amount Settled'][0]);
body.replaceText("{Total No. of Cancelled Bills During the Day}", info['Total No. of Cancelled Bills During the Day'][0]);
body.replaceText("{S.No.//Name of Person// Mobile No// Bill No// Bill Amount}", info['S.No.//Name of Person// Mobile No// Bill No// Bill Amount'][0]);
body.replaceText("{S.No.// Bill No// Mode of Payment//Tip Amount Received}", info['S.No.// Bill No// Mode of Payment//Tip Amount Received'][0]);
body.replaceText("{No. of Cylinders Received at Outlet}", info['No. of Cylinders Received at Outlet'][0]);
openDoc.saveAndClose();
const blobPDF = newTempFile.getAs(MimeType.PDF);
const pdfFile = pdfFolder.createFile(blobPDF).setName(info['Name of Outlet'][0]+ " " + info['Date of Report'][0]);
tempFolder.removeFile(newTempFile);
return pdfFile;
}
This script is not generating PDF as well PDF is not being Mailed.
The link of Spreadsheet is as below
https://docs.google.com/spreadsheets/d/1m6Aca0TcLf5UZ7P9CvAdQDokoazQljsqDT6CGh0K3j4/edit?usp=sharing
Please guide.

python BeautifulSoup not getting text from webpage

I am trying to get product name from the webpage using python. but it returns only a empty tags. i also tried requests library and lxml parsing in BeautifulSoup. pls help me to fix this problem, thanks in advance :-)
HTML in site:
<div class="product-name">SWAN</div>
<div class="product-price">
<span class="final-price">₹10650</span>
</div>
<div class="specification">
<div>Specifications</div>
<table>
<tr>
<td>....</td>
</tr>
<tr>
<td>....</td>
</tr>
</table>
</div>
python code:
url = "http://opor.in/ProductDetail/Index?ProductId=212"
page = urlopen(url).read()
html = bs(page, 'html.parser')
model_name = html.find('div', attrs={'class':'product-name'})
spec = html.find('div', attrs={'class':'specification'})
print(model_name)
print(spec)
Output:
<div class="product-name"></div>
<div class="specification">
<div>Specifications</div>
<table></table>
</div>
The data loaded by java-scripts.However if you see the DOM data available in script tag.To fetch the value from script tag and load into json and then get the key value.
Code:
from urllib.request import urlopen
from bs4 import BeautifulSoup as bs
import json
url = "http://opor.in/ProductDetail/Index?ProductId=212"
page = urlopen(url).read()
soup = bs(page, 'html.parser')
for item in soup.find_all('script'):
if 'productDetail' in item.text:
data=item.text.split('var productDetail =')[-1].split('};')[0] + "}"
datajson=json.loads(data.strip())
print('Product Code :' + datajson['ProductCode'])
for item in datajson['ProductSpecification']:
print(item['SpecificationName'] + " : "+ item['SpecificationValue'])
Output:
Product Code :1601KFMB
MEMBRANE : MEMBRELLA -ALPHA- 80 GPD (2 NOS)
PUMP : KEMFLO 48 V
APPLICATION : SUITABLE FOR BRACKISH WATER
FILTER LIFE : APPROX 3000 LITRE / 6 MONTHS
FILTERS : SEDIMENT, PRECARBON, POST CARBON
FLOAT : MEMBRELLA
FR : MEMBRELLA /KFL
INLINE SET : MEMBRELLA
INPUT VOLTAGE : 100-300 VOLT AC (50Hz)
INSTALLATION : COUNTER TOP
MAX.OPERATION TDS : 4000 PPM
MEMBRANE TYPE : THIN FILM COMPOSITE
MIN.INLET PRESSURE / TEMP : 0.3 kg / cm2, 10 °C
MODEL : WHALE 25
OPERATING VOLTAGE : 48 VOLT (DC)
PRODUCT DIMENSION : 21.1 (H) x 9.9 (W) x 16.7 (L)
PURIFICATION CAPACITY : 25 LITRES PER HOUR
RECOVERY RATE : MORE THAN 30% AT 27°c ± 2°c
SMPS : MEMBRELLA / EQUALIANT
SOLENOID VALVE : MEMBRELLA / SLX
STORAGE CAPACITY : 20 LITRES
TECHNOLOGY : REVERSE OSMOSIS SYSTEM
TOTAL POWER CONSUMPTION : 50 W
TUBE 1/4 : 5 METERS
TUBE 3/8 : 2 METERS
WEIGHT : 18 kg (Approx)
WARRENTY & SUPPORT : Since Whale designs its purifiers and many of its parts are a truly integrated system. Dealer only can provide one-stop service ,guaranty and support for any service and maintenance, so most issues can be resolved in a single visit
The data you are searching are actually loaded by javascript. You have to use a package such as selenium to retrieve the data.
You can try this:
CODE:
from bs4 import BeautifulSoup as bs
from selenium import webdriver
import requests
from selenium.webdriver.firefox.options import Options as FirefoxOptions
# Use options to have your selenium headless
options = FirefoxOptions()
options.add_argument("--headless")
driver = webdriver.Firefox(options=options)
url = "http://opor.in/ProductDetail/Index?ProductId=212"
driver.get(url)
page = driver.page_source
html = bs(page, 'html.parser')
model_name = html.find('div', {'class':'product-name'})
spec = html.find('div', {'class':'specification'})
print(model_name)
print(spec)
RESULTS:
<div class="product-name">WHALE 25 LPH</div>
<div class="specification">
<div>Specifications</div>
<table><tr><td class="specification-group" colspan="2"><div>General</div></td></tr><tr><td>Product Code</td><td>1601KFMB</td></tr><tr><td>MEMBRANE</td><td>MEMBRELLA -ALPHA- 80 GPD (2 NOS)</td></tr><tr><td>PUMP</td><td>KEMFLO 48 V</td></tr><tr><td class="specification-group" colspan="2"><div>Specifications</div></td></tr><tr><td>APPLICATION</td><td>SUITABLE FOR BRACKISH WATER</td></tr><tr><td>FILTER LIFE</td><td>APPROX 3000 LITRE / 6 MONTHS</td></tr><tr><td>FILTERS</td><td>SEDIMENT, PRECARBON, POST CARBON</td></tr><tr><td>FLOAT</td><td>MEMBRELLA</td></tr><tr><td>FR</td><td>MEMBRELLA /KFL</td></tr><tr><td>INLINE SET</td><td>MEMBRELLA</td></tr><tr><td>INPUT VOLTAGE</td><td>100-300 VOLT AC (50Hz)</td></tr><tr><td>INSTALLATION</td><td>COUNTER TOP</td></tr><tr><td>MAX.OPERATION TDS</td><td>4000 PPM</td></tr><tr><td>MEMBRANE TYPE</td><td>THIN FILM COMPOSITE</td></tr><tr><td>MIN.INLET PRESSURE / TEMP</td><td>0.3 kg / cm2, 10 °C</td></tr><tr><td>MODEL</td><td>WHALE 25</td></tr><tr><td>OPERATING VOLTAGE</td><td>48 VOLT (DC)</td></tr><tr><td>PRODUCT DIMENSION</td><td>21.1 (H) x 9.9 (W) x 16.7 (L)</td></tr><tr><td>PURIFICATION CAPACITY</td><td>25 LITRES PER HOUR</td></tr><tr><td>RECOVERY RATE</td><td>MORE THAN 30% AT 27°c ± 2°c</td></tr><tr><td>SMPS</td><td>MEMBRELLA / EQUALIANT</td></tr><tr><td>SOLENOID VALVE</td><td>MEMBRELLA / SLX</td></tr><tr><td>STORAGE CAPACITY</td><td>20 LITRES</td></tr><tr><td>TECHNOLOGY</td><td>REVERSE OSMOSIS SYSTEM</td></tr><tr><td>TOTAL POWER CONSUMPTION</td><td>50 W</td></tr><tr><td>TUBE 1/4</td><td>5 METERS</td></tr><tr><td>TUBE 3/8</td><td>2 METERS</td></tr><tr><td>WEIGHT</td><td>18 kg (Approx)</td></tr><tr><td>WARRENTY & SUPPORT</td><td>Since Whale designs its purifiers and many of its parts are a truly integrated system. Dealer only can provide one-stop service ,guaranty and support for any service and maintenance, so most issues can be resolved in a single visit</td></tr></table>
</div>

Convert text to integer and if higher than 50 alert

On our current website that is hosted offsite via another company it is all done with .NET, I simply have access to HTML, JS, and CSS files to edit. A lot of data is output on the page via tokens. On our web page we have a weight token, it grabs the items weight and outputs it between a span tag. So if you're viewing the source it'll show the following:
<span id="order_summary_weight">78.000000 lbs</span>
The token by default outputs the lbs. What I need to do is have javascript grab the 78.000000, convert it to an integer I'm assuming and if that integer, in this case 78.000000 is greater than 50.000000 I'd like it append a line after the 78.000000 lbs to say "Your weight total is over 50 lbs, we will contact you directly with a shipping charge." Understand some weight totals may be as small as 0.010000
I'm coming to you fine folks here because I am at a complete lost where to start in this endeavor.
Something like this ? :
html :
<div class="wrap">
<span class="price" id="order_summary_weight">78.000000 lbs</span>
</div>
<hr>
<div class="wrap">
<span class="price" id="order_summary">50.000000 lbs</span>
</div>
JS :
$('.wrap').each(function(){
var price = $(this).find('.price').text();
price = price.replace(' lbs', '');
price = parseInt(price);
if(price > 50){
$(this).append('<div class="alert">Your weight total is over 50 lbs, we will contact you directly with a shipping charge.</div>');
}
});
DEMO : http://jsfiddle.net/w3qg4/1/
function getWeight()
{
var x=document.getElementById("order_summary_weight");
if(x > 50){
alert("Your weight total is over 50 lbs, we will contact you directly with a shipping charge. Understand some weight totals may be as small as 0.010000");
}
}

Categories