Last active
October 8, 2018 17:40
-
-
Save scheibome/f427ef4673285e8a36c3b4c8391d09ad to your computer and use it in GitHub Desktop.
multi shipping in tinystoragecart checkout
This file contains hidden or 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
<select id="shippingselect"> | |
<option disabled selected value>Select</option> | |
<option value="2" data-shippingselect="15">Europe Shipping +15€</option> | |
<option value="3" data-shippingselect="35">International Shiping +35€</option> | |
</select> |
This file contains hidden or 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
var $cartcheckoutshippingselection = document.getElementById('shippingselect'); | |
if ($cartcheckoutshippingselection) { | |
$cartcheckoutshippingselection.addEventListener('change', function(e) { | |
$singleShipping.dataset.shippingcost = e.target.selectedOptions[0].dataset.shippingselect; | |
requirejs(['cart/cart'], function(cart) { | |
document.dispatchEvent( | |
new CustomEvent('calculateCartSum', { | |
detail: { | |
cart: cart.getStorageCart(), | |
cartTotal: cart.calculateTotal(), | |
cartObject: cart | |
} | |
}) | |
); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment