Skip to content

Instantly share code, notes, and snippets.

@jp26jp
Last active July 5, 2016 19:21
Show Gist options
  • Save jp26jp/503d409c152752fe1d5b1b209dea9fad to your computer and use it in GitHub Desktop.
Save jp26jp/503d409c152752fe1d5b1b209dea9fad to your computer and use it in GitHub Desktop.
Remove all stored keys in Ecwid
var keyNames = [];
// function to delete each key from storage one by one
deleteAllStorageData = function (array){
for (i=0; i < array.length; i++) {
$.ajax({
url: 'https://app.ecwid.com/api/v3/' + storeId + '/storage/' + array[i] + '?token=' + accessToken,
type: 'DELETE'
})
}
console.log('DELETED');
getStorageKeys();
}
// fill in keyNames array with all existing keys
getStorageKeys = function(){
EcwidApp.getAppStorage(function(allKeys) {
for (i=0; i < allKeys.length; i++) {
keyNames.push(allKeys[i].key);
}
// print out all key names in storage
console.log(keyNames);
if (keyNames.length > 0) {
deleteAllStorageData(keyNames);
} else {
return;
}
})
};
getStorageKeys();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment