function delete_product(product_id, confirm) { if (!confirm) { var p = $('
') .addClass('note error') .append("Are you sure you want to delete the product?Deleting product...
"); $.ajax({ url: '/admin/products/' + product_id, type: 'delete', success: function(resp) { if (resp.error) modal.autosize("" + resp.error + "
"); if (resp.redirect) window.location = resp.redirect; } }); } function cancel_delete_product(product_id) { var p = $('').append($("").attr('type', 'button').val('Delete this product').click(function() { delete_product(product_id); })); modal.autosize(p); } function add_variant(product_id) { modal.autosize("Adding variant...
"); $.ajax({ url: '/admin/products/' + product_id + '/variants', type: 'post', success: function(resp) { if (resp.error) modal.autosize("" + resp.error + "
"); if (resp.refresh) window.location.reload(true); } }) } function delete_variant(variant_id, confirm) { if (!confirm) { var p = $('') .addClass('note error') .append("Are you sure you want to delete the variant?Deleting product...
"); $.ajax({ url: '/admin/variants/' + variant_id, type: 'delete', success: function(resp) { if (resp.error) modal.autosize("" + resp.error + "
"); if (resp.redirect) window.location = resp.redirect; } }); } function cancel_delete_variant(variant_id) { var link = $('').attr('href','#').click(function(e) { e.preventDefault(); delete_variant(variant_id); }); modal.autosize(link); }