1if (typeof(JS_WP_ESTORE_VARIATION_ADD_STRING) == 'undefined') { 2 JS_WP_ESTORE_VARIATION_ADD_STRING = "+"; 3} 4if (typeof(JS_WP_ESTORE_CURRENCY_SYMBOL) == 'undefined') { 5 JS_WP_ESTORE_CURRENCY_SYMBOL = "$"; 6} 7if (typeof(JS_WP_ESTORE_VARIATION_DECIMAL_SEPERATOR) == 'undefined') { 8 JS_WP_ESTORE_VARIATION_DECIMAL_SEPERATOR = "."; 9} 10if (typeof(JS_WP_ESTORE_VARIATION_THOUSAND_SEPERATOR) == 'undefined') { 11 JS_WP_ESTORE_VARIATION_THOUSAND_SEPERATOR = ","; 12} 13if (typeof(JS_WP_ESTORE_MINIMUM_PRICE_YOU_CAN_ENTER) == 'undefined') { 14 JS_WP_ESTORE_MINIMUM_PRICE_YOU_CAN_ENTER = "The minimum amount you can specify is "; 15} 16if (typeof(JS_WP_ESTORE_SELECT_OPTION_STRING) == 'undefined') { 17 JS_WP_ESTORE_SELECT_OPTION_STRING = "Select Option"; 18} 19if (typeof(JS_WP_ESTORE_SELECT_OPTION_ERROR_MSG) == 'undefined') { 20 JS_WP_ESTORE_SELECT_OPTION_ERROR_MSG = "You need to slect an option before you can proceed."; 21} 22variation_add_string = JS_WP_ESTORE_VARIATION_ADD_STRING;//"+"; 23currency_symbol = JS_WP_ESTORE_CURRENCY_SYMBOL;//"$"; 24decimal_sep = JS_WP_ESTORE_VARIATION_DECIMAL_SEPERATOR;//"."; 25thousands_sep = JS_WP_ESTORE_VARIATION_THOUSAND_SEPERATOR;//","; 26split_char = "[" + variation_add_string; 27variation_select_option = JS_WP_ESTORE_SELECT_OPTION_STRING; 28 29function CheckTok(object1) 30{ 31 var var_add_amt, ary = new Array(); // where we parse 32 ary = val.split("["); // break apart 33 variation_price_val = ary[1]; 34 if (variation_price_val != null) 35 { 36 //remove the addition,currency and ] symbol then trim it 37 var_add_amt = variation_price_val.replace(variation_add_string, ""); 38 var_add_amt = var_add_amt.replace(currency_symbol, ""); 39 var_add_amt = var_add_amt.replace("]", ""); 40 var_add_amt = var_add_amt.replace(thousands_sep, ""); 41 var_add_amt = var_add_amt.replace(thousands_sep, "");//one extra for the million separator 42 if (decimal_sep != ".") { 43 var_add_amt = var_add_amt.replace(decimal_sep, "."); 44 } 45 var_add_amt = trim(var_add_amt); 46 if (eStoreIsNumeric(var_add_amt)) { 47 amt = amt + var_add_amt * 1.0; 48 } 49 else { 50 alert("Error! Variation addition amounts are not numeric. Please contact the admin and mention this error."); 51 } 52 } 53} 54function ReadForm1(object1, buttonType) 55{ 56 // Read the user form 57 var i, j, pos; 58 amt = 0; 59 val_total = ""; 60 val_combo = ""; 61 val_1st_half = ""; 62 variation_name = ""; 63 64 for (i = 0; i < object1.length; i++) 65 { 66 // run entire form 67 obj = object1.elements[i]; // a form element 68 69 if (obj.type == "select-one") 70 { // just selects 71 if (obj.name == "quantity" || 72 obj.name == "amount") 73 continue; 74 pos = obj.selectedIndex;// which option selected 75 val = obj.options[pos].value;// selected value 76 variation_name = val.split(split_char);// break apart 77 estore_product_id = object1.item_number.value; 78 if(variation_name[0].toLowerCase() == variation_select_option.toLowerCase()){ 79 //The customer hasn't selected a valid variation option. Show error message. 80 eStore_error_msg_for_variation_select(estore_product_id); 81 return false; 82 } else { 83 //Clear variation error msg (if any) 84 eStore_clear_error_msg_for_variation_select(estore_product_id); 85 } 86 87 val_combo = val_combo + " (" + trim(variation_name[0]) + ")"; 88 CheckTok(object1); 89 } 90 if (obj.type == "text" || obj.type == "textarea") 91 { 92 // Read the text fields 93 //Ignore the following fields as they don't need to be captured. 94 if (obj.name == "add_qty") 95 continue; 96 if (obj.name == "custom_price") 97 continue; 98 if (obj.name == "cust_name") 99 continue; 100 if (obj.name == "cust_email") 101 continue; 102 103 val = obj.value;//custom text msg value 104 if (val.length != 0) 105 { 106 val = val.replace("(", "["); 107 val = val.replace(")", "]"); 108 val_combo = val_combo + " (" + val + ")"; 109 } 110 } 111 } 112 113 // Now summarize everything we have processed above 114 val_total = object1.product_name_tmp1.value + val_combo; 115 if (buttonType == 1) 116 { 117 object1.estore_product_name.value = val_total; 118 var price_after_var_change; 119 if (object1.custom_price) { 120 var custom_price = parseFloat(object1.custom_price.value); 121 if (!eStore_custom_price_validated(object1, custom_price)) { 122 return false;
123 } 124 price_after_var_change = custom_price;//custom price overrides the price 125 } 126 else { 127 price_after_var_change = parseFloat(object1.price_tmp1.value) + amt; 128 } 129 updatePriceAmtText(object1, price_after_var_change, buttonType); 130 updateOldPriceAmtText(object1, amt, buttonType); 131 object1.price.value = price_after_var_change; 132 } 133 else if (buttonType == 2) 134 { 135 object1.item_name.value = val_total; 136 if (object1.custom_price) { 137 var custom_price = parseFloat(object1.custom_price.value); 138 if (!eStore_custom_price_validated(object1, custom_price)) { 139 return false; 140 } 141 else { 142 var price_after_var_change = custom_price + amt; 143 updatePriceAmtText(object1, price_after_var_change, buttonType); 144 updateOldPriceAmtText(object1, amt, buttonType); 145 object1.amount.value = price_after_var_change.toFixed(2); 146 } 147 } 148 else { 149 var price_after_var_change = parseFloat(object1.price_tmp1.value) + amt; 150 updatePriceAmtText(object1, price_after_var_change, buttonType); 151 updateOldPriceAmtText(object1, amt, buttonType); 152 object1.amount.value = price_after_var_change.toFixed(2); 153 } 154 setCookie("cart_in_use", "true", 1); 155 } 156 else if (buttonType == 3) 157 { 158 object1.item_name.value = val_total; 159 if (object1.custom_price) { 160 var custom_price = parseFloat(object1.custom_price.value); 161 if (!eStore_custom_price_validated(object1, custom_price)) { 162 return false; 163 } 164 else { 165 updated_amt = custom_price + amt; 166 object1.a3.value = updated_amt.toFixed(2); 167 } 168 } 169 else { 170 updated_amt = parseFloat(object1.price_tmp1.value) + amt; 171 object1.a3.value = updated_amt.toFixed(2); 172 } 173 setCookie("cart_in_use", "true", 1); 174 } 175 else if (buttonType == 4) 176 { 177 object1.product.value = val_total; 178 } 179} 180function trim(stringToTrim) { 181 return stringToTrim.replace(/^\s+|\s+$/g, ""); 182} 183function setCookie(c_name, value, expiredays) 184{ 185 var exdate = new Date(); 186 exdate.setDate(exdate.getDate() + expiredays); 187 document.cookie = c_name + "=" + escape(value) + 188 ((expiredays == null) ? "" : ";expires=" + exdate.toUTCString()); 189} 190function eStoreIsNumeric(input) 191{ 192 return (input - 0) == input && input.length > 0; 193} 194function eStore_custom_price_validated(object1, custom_price) 195{ 196 var min_amt = parseFloat(object1.price_tmp1.value); 197 if (isNaN(custom_price) || custom_price < min_amt) 198 { 199 alert(JS_WP_ESTORE_MINIMUM_PRICE_YOU_CAN_ENTER + min_amt); 200 return false; 201 } 202 return true; 203} 204function updatePriceAmtText(object1, new_price, buttonType) { 205 jQuery(document).ready(function($) {//update the price text amount 206 var old_price; 207 if (buttonType == 1) { 208 old_price = parseFloat(object1.price.value); 209 } else if (buttonType == 2) { 210 old_price = parseFloat(object1.amount.value); 211 } 212 new_price = parseFloat(new_price); 213 if (old_price == new_price) {//No price value changed 214 return; 215 } 216 new_price = new_price.toFixed(JS_WP_ESTORE_VARIATION_NUM_OF_DECIMALS); 217 if (decimal_sep != ".") {//Non english system 218 new_price = new_price.replace(".", decimal_sep); 219 } 220 221 var new_prod_price_text = JS_WP_ESTORE_CURRENCY_SYMBOL + new_price; 222 if (JS_WP_ESTORE_VARIATION_CURRENCY_POS == 'right') { 223 new_prod_price_text = new_price + JS_WP_ESTORE_CURRENCY_SYMBOL; 224 } 225 var jq_obj = $(object1); 226 var curr_prod_div = jq_obj.closest('.eStore-fancy-wrapper'); 227 curr_prod_div.find('.eStore_price_value').text(new_prod_price_text); 228 }); 229} 230function updateOldPriceAmtText(object1, amt, buttonType) { 231 jQuery(document).ready(function($) {//update the price text amount 232 var jq_obj = $(object1); 233 var curr_prod_div = jq_obj.closest('.eStore-fancy-wrapper'); 234 var cutoff_price_display_val = curr_prod_div.find('.eStore_price_value_old').text(); 235 if (cutoff_price_display_val) //cut off price is being displayed 236 { 237 var new_cuttoff_price = parseFloat(object1.price_tmp1_old.value) + amt; 238 new_cuttoff_price = new_cuttoff_price.toFixed(JS_WP_ESTORE_VARIATION_NUM_OF_DECIMALS); 239 if (decimal_sep != ".") {//Non english system 240 new_cuttoff_price = new_cuttoff_price.replace(".", decimal_sep); 241 } 242 var new_cuttoff_price_text = JS_WP_ESTORE_CURRENCY_SYMBOL + new_cuttoff_price; 243 if (JS_WP_ESTORE_VARIATION_CURRENCY_POS == 'right') { 244 new_cuttoff_price_text = new_cuttoff_price + JS_WP_ESTORE_CURRENCY_SYMBOL; 245 } 246 247 curr_prod_div.find('.eStore_price_value_old').text(new_cuttoff_price_text); 248 } 249 }); 250} 251function eStore_error_msg_for_variation_select(product_id) { 252 jQuery(document).ready(function($) { 253 var jq_product_id = $(product_id); 254 //alert(JS_WP_ESTORE_SELECT_OPTION_ERROR_MSG); 255 html_error_msg = '<div class="eStore_error_variation_not_selected eStore_error_message">' + JS_WP_ESTORE_SELECT_OPTION_ERROR_MSG + '</div>'; 256 $(".eStore_item_added_msg-" + product_id).html(html_error_msg); 257 }); 258} 259function eStore_clear_error_msg_for_variation_select(product_id) { 260 jQuery(document).ready(function($) { 261 $(".eStore_error_variation_not_selected").html(""); 262 }); 263}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.