A Pen by John Leschinski on CodePen.
Created
September 20, 2017 16:34
-
-
Save picard102/d8866cb0a7a582e5d822efc223f109ec to your computer and use it in GitHub Desktop.
JrGJxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table> | |
<tr id="subtotalRow"> | |
<td colspan="3">Sub total</td> | |
<td class="colPrice money fr-CA">4.99</td> | |
</tr> | |
</table> | |
<div class="shipr-0"> | |
<label class="shipping"> | |
<input onclick="ShippingClick(this)" type="radio" name="shipping" class="shippingDetail" value="13" pobox="False" data-shipment="Value - $4.99"/> <strong>Value - $4.99</strong> | |
Delivered within 10 days. Free Standard Shipping on all orders over $25.00 (before tax). $4.99 for orders up to $24.99 | |
</label> | |
<label class="shipping"> | |
<input onclick="ShippingClick(this)" type="radio" name="shipping" class="shippingDetail" value="14" pobox="False" data-shipment="Express – $8.99 for orders up to $75 (before tax) "/> <strong>Express – $8.99 for orders up to $75 (before tax) </strong> | |
Add $1.50 for each additional $75. Delivered within 1 to 2 business days. Ideal for New Release orders! | |
</label> | |
<label class="shipping"> | |
<input onclick="ShippingClick(this)" type="radio" name="shipping" class="shippingDetail" value="40" pobox="False" data-shipment="Skip the "Free" Line - $3.99"/> <strong>Skip the "Free" Line - $3.99</strong> | |
Delivered within 5 business days. Please note that additional shipping charges will apply for orders shipping to a PO Box. | |
</label> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ($('#subtotalRow').length) { | |
var subtotal = $("#subtotalRow .colPrice").text().replace(/\,/g, '.'); | |
var limit = "34.99"; | |
var diff = limit - subtotal; | |
var lang = $("#subtotalRow .colPrice"); | |
if ( $( lang ).hasClass( 'en-CA' ) ) { | |
var lang = 'en'; | |
var text_value = "<strong>Value - $4.99</strong> Delivered within 10 business days. Spend an additional <strong>$" + diff.toFixed(2) + "</strong> before tax to qualify for free shipping!"; | |
var text_free = "<strong>FREE - </strong>Delivered within 10 business days. Please note that shipping charges will apply for orders shipping to a PO Box."; | |
} else { | |
var lang = 'fr'; | |
var text_value = "<strong>Value - 4,99 $</strong> Delivered within 10 business days. Spend an additional <strong>" + diff.toFixed(2).replace(/\./g, ',') + " $</strong> before tax to qualify for free shipping!"; | |
var text_free = "<strong>FREE - </strong>Delivered within 10 business days. Please note that shipping charges will apply for orders shipping to a PO Box."; | |
} | |
//console.log( 'LANG : ' + lang ); | |
//console.log( 'VALUE : ' + subtotal ); | |
//console.log( 'LIMIT : ' + limit ); | |
//console.log( 'DIFF : ' + diff.toFixed(2) ); | |
var value_ship = $('.shipgr-0 .shippingDetail[value="13"]'); | |
var skip_ship = $('.shipgr-0 .shippingDetail[value="40"]'); | |
var exp_ship = $('.shipgr-0 .shippingDetail[value="14"]'); | |
//console.log( 'INPUT : ' + input ); | |
$(exp_ship).parent().insertBefore( $(value_ship).parent() ); | |
$(skip_ship).parent().insertBefore( $(value_ship).parent() ); | |
$(value_ship) | |
.parent() | |
.contents() | |
.filter(function() { | |
return this.nodeType === 3; | |
}) | |
.remove(); | |
$(value_ship).parent().find("strong").remove(); | |
if (diff > 0) { | |
var text = text_value; | |
$(skip_ship).parent().remove(); | |
} else { | |
var text = text_free; | |
} | |
$(value_ship).after(text); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
label { | |
display: block; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment