var element = 'Save Cart As Link';
$(document).ready( function() {
$(element).insertBefore( $('#content a[href="https://weload.sg/index.php?route=checkout/checkout"]') ).show();
$('#save-cart-button').on('click', function() {
var $this = $(this);
$this.button('loading');
$.ajax({
url: 'index.php?route=extension/module/save_cart/createCartLink',
dataType: 'json',
success: function(result) {
$.MessageBox({
input: result.url,
buttonDone: result.text_copy
}).done(function(data){
copyToClipboard(result.url);
});
},
complete: function() {
$('#save-cart-button').button('reset');
}
});
});
});
function copyToClipboard(text) {
var $temp = $("");
$("body").append($temp);
$temp.val(text).select();
document.execCommand("copy");
$temp.remove();
}