A operate is created to be known as when a change occasion happens on a span
tag as seen within the code snippet beneath.
$(".price-box").on("change", ".normal-price .price-wrapper span.worth", operate() {
console.log('Hey, I'm comfortable to be known as');
// Get the worth of the span component
var worth = $(".price-box .normal-price .price-wrapper span.worth").html();
// Clear and Convert the worth to cents
var priceCents = parseInt(parseFloat(worth.change(/[^d.]/g,'')) * 100);
// If worth is completely different from current Klarna product placement worth, replace it.
// after which name Klarna with refresh-event to refresh the position.
var oldPurchaseAmt = $(".product-add-form klarna-placement").attr("data-purchase-amount");
if (priceCents != oldPurchaseAmt) {
$(".product-add-form klarna-placement").attr("data-purchase-amount", priceCents);
// Set off occasion to refresh
window.KlarnaOnsiteService = window.KlarnaOnsiteService || [];
window.KlarnaOnsiteService.push({ eventName: 'refresh-placements' });
}
});
Under is the entire JS file together with the above code snippet.
operate get_pmm_shipping_text() {
var v_text = "",
exceptions="MB TB OM",
notFree="BB,LC,TB,JA,MD",
ship_info="",value="",free="",p=0,
little_truck= '<img src="https://photographs.perfectshoppers.com/4b15739013799.png" class="altattr" alt="Free Delivery">';
// NOTE: pmm_vendor_code, pmm_sku and pmm_price are pre-existing variables
console.log("Vendor Code=" + pmm_vendor_code + ", SKU=" + pmm_sku + "Worth=" + pmm_price);
notFree.indexOf(pmm_vendor_code)>-1 ? free="" : free = "FREE,"; // if prefix not in "notFree" variable, transport is FREE no matter worth.
pmm_price > 49 ? free="FREE," : free="" ; // every little thing over $49 ships free.
// thresh>"" && netprice<thresh ? free="" : ''; // beneath transport threshold nullifies free transport (thresh and netprice will not be outlined)
pmm_vendor_code == "E2" ? free = "FREE," : ""; // forces FREE for E2 (Electrical Mirror alternate vendor code)
change(pmm_vendor_code){ // exceptions gadgets to vendor Free or Not-Free
case "BB" : pmm_sku == "BB01" ? free = "FREE," : '' ;
case "JA" : pmm_price > "32" ? free = "FREE," : '';
case "MD" : pmm_price > "32" ? free = "FREE," : '';
case "LC" : pmm_price > "57" ? free = "FREE," : '';
}
// REMEMBER free (decrease case) is a variable
value = "In inventory! Shipped "+free+" often on the ";
change (pmm_vendor_code){
case "AB" : ship_info=value+"1<sup>st</sup> or 2<sup>nd</sup> " ; break; // Amba
case "AG" : ship_info=value+"1<sup>st</sup> or 2<sup>nd</sup> " ; break; // alkaglam
case "AY" : ship_info=value+"2<sup>nd</sup> to 4<sup>th</sup> "; break; // ayurderm
case "BB" : ship_info=value+"subsequent " ; break; // NOT free -butterbabes
case "CL" : ship_info=value+"2<sup>nd</sup> to 4<sup>th</sup> " ; break; // clear mirror
case "CB" : ship_info=value+"identical or subsequent "; break; // cannaBon
case "CP" : ship_info=value+"1<sup>st</sup> or 2<sup>nd</sup> " ; break; // contrapac
case "CY" : ship_info=value+"identical or subsequent " ; break; // cyberderm
case "DB" : ship_info=value+"identical or subsequent " ; break; // Pricey by Renee
case "DN" : ship_info=value+"subsequent " ; break; // dia naturals
case "E2" : ship_info=value+"6<sup>th</sup> to eight<sup>th</sup> " ; break; // electrical mirror backlit mirrors
case "E3" : ship_info=value+"3<sup>rd</sup> to six<sup>th</sup> " ; break; // electrical mirror Cordova model
case "EM" : ship_info=value+"2<sup>nd</sup> to 4<sup>th</sup> " ; break; // electrical mirror
case "FS" : ship_info=value+"2<sup>nd</sup> " ; break; // foster and lake
case "GH" : ship_info=value+"1<sup>st</sup> or 2<sup>nd</sup> " ; break; // stan pardente ghd
case "HR" : ship_info=value+"identical or subsequent "; break; // hair restoration
case "JA" : ship_info=value+"identical or subsequent " ; break; // JAVA skincare
case "JD" : ship_info=value+"2<sup>nd</sup> ";break; // Jerdon
case "KY" : ship_info=value+"1<sup>st</sup> or 2<sup>nd</sup> "; break; // kimball & younger / aptations
case "LC" : ship_info=value+"identical or subsequent "; break; // l.a. christine
case "LU" : ship_info=value+"identical or subsequent "; break; // luce skincare
case "LW" : ship_info=value+"1<sup>st</sup> or 2<sup>nd</sup> " ; break; // stemulation
case "MD" : ship_info=value+"1<sup>st</sup> or 2<sup>nd</sup> "; break; // MDSolarSciences
case "MH" : ship_info=value+"2<sup>nd</sup> to three<sup>rd</sup> " ; break; // extra hair naturally
case "MY" : ship_info=value+"2<sup>nd</sup> to three<sup>rd</sup> " ; break; // marcus york
case "RE" : ship_info=value+"identical or subsequent "; break; // replete skincare
case "NO" : ship_info=value+"identical or subsequent "; break; // gentleman's foundry
case "SK" : ship_info=value+"subsequent " ; break; // pores and skin triks
case "SQ" : ship_info=value+"identical or subsequent " ; break; // skintifique
case "SY" : ship_info=value+"2<sup>nd</sup> or 3<sup>rd</sup>" ; break; // shunly
case "TB" : ship_info=value+"2<sup>nd</sup> or 3<sup>rd</sup>" ; break; // to bee merchandise
case "TH" : ship_info=value+"1<sup>st</sup> or 2<sup>nd</sup> " ; break; // thalgo
case "UC" : ship_info=value+"2<sup>nd</sup> to 4<sup>th</sup>";break; // higher canada (danielle creations)
case "VT" : ship_info=value+"subsequent " ; break; // classic traditions
case "xx" : ship_info=value+"identical or subsequent"; break; // pmm stock product
}
console.log("Ship Information=" + ship_info);
if (exceptions.indexOf(pmm_vendor_code)==-1){ // if vendor will not be within the exceptions string use the instances above
if (free=="FREE," || pmm_vendor_code == "E2"){ // show the little truck // E2 to pressure it for E2 - would not work in any other case
v_text = little_truck + ' <robust>' + ship_info + ' enterprise day.</robust>';
} else { // no little truck
v_text = '<robust> ' + ship_info +' enterprise day.</robust>';
}
} else { // following distributors are within the exceptions string
change (pmm_vendor_code){
case "MB" : v_text = '<span type="coloration:#A300FC;font-size:1.1em;font-weight:daring" >'+little_truck+' Shipped FREE, on to you through <span type="coloration:#FF0000">FedEx Worldwide Specific</span> in about 14-21 days, immediately from Paris, France.</span>'; break; // miroir brot
case "OM" : v_text = '<span type="font-size:1.1em;font-weight:daring">'+little_truck+' eight oz. dimension ships FREE.<br />Additionally shipped FREE: 2 oz. dimension bought along with eight oz. dimension - or - Three or extra 2 oz. dimension.<br /><br />Cargo is from Canada after 1 enterprise day. Time in transit to places within the continental US is Three to five enterprise days.</span>'; break; // oil me north
case "TB" : v_text = '<span type="font-size:1.1em;font-weight:daring">Ships FREE when bought along with ToBee 3-Pack</span>'; break; // to bee merchandise
}
}
console.log("V Textual content=" + v_text);
return v_text;
} // finish of get_pmm_shipping_text()
// --------------------------------- miroir brot trip --------------------------------------------------------
/*if(docloch.indexOf("miroir-brot")>-1){
var brot_start = new Date(2019,06,28),
brot_end = new Date(2019,07,30);
if (today_date => brot_start && today_date <= brot_end){
$(".product-name").after('<div id="brot_vacation" type="text-align: left;font-size: giant; coloration: #9900ff;">Miroir Brot might be CLOSED for summer time trip from August fifth by August 30th.<br /><br /><robust>Order by <span type="coloration: #ff0000;">Thursday, July 25th</span> for cargo earlier than trip closing.</robust><br /><br />Orders positioned after July 25th might be shipped after August 30th.</div>');
}
} */
// Usually add the bind to a guardian which might be secure.
$(".price-box").on("change", ".normal-price .price-wrapper span.worth", operate() {
console.log('Hey, I'm comfortable to be known as');
// Get the worth of the span component
var worth = $(".price-box .normal-price .price-wrapper span.worth").html();
// Clear and Convert the worth to cents
var priceCents = parseInt(parseFloat(worth.change(/[^d.]/g,'')) * 100);
// If worth is completely different from current Klarna product placement worth, replace it.
// after which name Klarna with refresh-event to refresh the position.
var oldPurchaseAmt = $(".product-add-form klarna-placement").attr("data-purchase-amount");
if (priceCents != oldPurchaseAmt) {
$(".product-add-form klarna-placement").attr("data-purchase-amount", priceCents);
// Set off occasion to refresh
window.KlarnaOnsiteService = window.KlarnaOnsiteService || [];
window.KlarnaOnsiteService.push({ eventName: 'refresh-placements' });
}
});
outline([
'jquery',
'domReady!'
], operate($) {
var docloch=doc.location.href,new_title="";
// Commented out because the Tab will not be opening by default.
// $("#tab-label-product.data.description").click on();
setTimeout(operate() {
$("#pmm_shipping").html('<br><div type="margin:-40px 0 15px">'+get_pmm_shipping_text()+'</div>');
}, 750); // finish of setTimeout
// make the phrase CLOSEOUT crimson on product pages
if ($("h1").textual content().indexOf("CLOSEOUT!")>-1 || $("h1").textual content().indexOf("OPEN BOX!")>-1){
var newT= $("h1").html();
newT = newT.change("CLOSEOUT!",'<span type="coloration:#FF0000">CLOSEOUT!</span>');
newT = newT.change("OPEN BOX!",'<span type="coloration:#FF0000">OPEN BOX!</span>');
$("h1").html(newT);
}
}); // finish of $ operate
Might you please level out the error being current which triggers Uncaught TypeError: $
will not be a functionThank you.