How to Change Shop Inventory Based on Past Purchases?

What I want: To update the inventory of a shop based on past purchases/items in inventory.

What I have: I have a shop which sells a set of items that have improved sequels. Blessing 1 -> Blessing 2 -> Blessing 3

Spoiler: Shop Event
1676090598494.png

What I need: A way to make the inventory change as items are acquired.
Eg. When player has Blessing of Death 1, add Blessing of Death 2 to shop & remove Blessing of Death 1 from shop.

I can obviously set an event to check for the player having items, but I don't know how to make the inventory change as a result. As far as I can tell it will need a script, but I can't find any examples of someone trying this before.

Can anyone help me figure this out?

P.S. I could have the item trigger a whole new shop processing event, but with 16 items the player can purchase in any order that event would quickly become a hundreds of pages long hydra.)
you'll need a plugin then, one that implements advanced control and stoc limits on the shop.

without a plugin the only way would have been what you mentioned, different shop processing.
Can't you just create one shop processing event (with the script event command) that has game variables in the array for those special items and then before the event put single line conditional checks that check if the party has one of those special items and then changes the variables used in the shop array as a result?

EDIT:
A pic just to show an example (in here the variable 20 was set to 7 in the beginning)

shop_process.JPG
This doesn't require a plugin. A script command such as this one should work:

JavaScript:
/* Change these values to represent the Item IDs of each blessing */
const blessings = [
    [id1, id2, id3],  // Blessing of Death
    [id1, id2, id3],  // Blessing of Field
    [id1, id2, id3],  // Blessing of Forest
    [id1, id2, id3],  // Blessing of Sea
    [id1, id2, id3],  // Blessing of Storm
    [id1, id2, id3],  // Blessing of Sun
    [id1, id2, id3],  // Blessing of Trickery
    [id1, id2, id3]   // Blessing of War
];

const goods = [];

blessings.forEach(blessing => {
    for (const id of blessing) {
        if (!$gameParty.hasItem($dataItems[id])) {
            goods.push([0, id, 0]);
            break;
        }
    }
});

if (goods.length > 0) {
    SceneManager.push(Scene_Shop);
    SceneManager.prepareNextScene(goods, true);
} else {
    $gameMessage.setFaceImage('Actor3', 3);
    $gameMessage.setBackground(0);
    $gameMessage.setPositionType(2);
    $gameMessage.setSpeakerName('Ninshubur');
    $gameMessage.add('You have already received all of the Goddess\' blessings!');
    this.setWaitMode('message');
}

You just have to edit the blessings array to contain the actual item IDs of each level of blessing. So for example if the item id of Blessing of Death I is 21, and the id of BoD II is 22, and the id of BoD III is 23, then you'd change this line:
JavaScript:
[id1, id2, id3],  // Blessing of Death
to this:
JavaScript:
[21, 22, 23],  // Blessing of Death

*Edited to account for the possibility that the player has already purchased all blessings.
I'm attempting Arthran's method but I've done something wrong.
I keep getting a syntax error for various different brackets.

The version below returns Syntax Error: Unexpected Token ')'
Here's the id list and my attempt at the script, I've pared it back to just one blessing for now until the error is solved.

Spoiler: Database items
1676157218778.png

JavaScript:
const blessings = [  
    [id34, id17, id18]   // Blessing of Moon
];

const goods = [];

blessings.forEach(blessing => {
    for (34) {
        if (!$gameParty.hasItem($dataItems[34])) {
            goods.push([0, 17, 0]);
            break;
blessings.forEach(blessing => {
    for (17) {
        if (!$gameParty.hasItem($dataItems[17])) {
            goods.push([0, 18, 0]);
        }
    }
});

SceneManager.push(Scene_Shop);
SceneManager.prepareNextScene(goods, true);
I'm attempting Arthran's method but I've done something wrong.
I keep getting a syntax error for various different brackets.

The version below returns Syntax Error: Unexpected Token ')'
Here's the id list and my attempt at the script, I've pared it back to just one blessing for now until the error is solved.

Spoiler: Database items

JavaScript:
const blessings = [
    [id34, id17, id18]   // Blessing of Moon
];

const goods = [];

blessings.forEach(blessing => {
    for (34) {
        if (!$gameParty.hasItem($dataItems[34])) {
            goods.push([0, 17, 0]);
            break;
blessings.forEach(blessing => {
    for (17) {
        if (!$gameParty.hasItem($dataItems[17])) {
            goods.push([0, 18, 0]);
        }
    }
});

SceneManager.push(Scene_Shop);
SceneManager.prepareNextScene(goods, true);
You edited a part that you're not supposed to edit, and you didn't edit the part that you were supposed to edit. The only part you should edit is the very top part. Based on the screenshot of your database, your script should look something like this:

JavaScript:
const blessings = [
    [8, 9, 10],  // Blessing of Death
    [11, 12, 13],  // Blessing of Field
    [14, 15, 16],  // Blessing of Forest
    [19, 20, 21],  // Blessing of Sea
    [22, 23, 24],  // Blessing of Storm
    [25, 26, 27],  // Blessing of Sun
    [28, 29, 30],  // Blessing of Trickery
    [31, 32, 33],  // Blessing of War
    [34, 17, 18]   // Blessing of Moon
];

const goods = [];

blessings.forEach(blessing => {
    for (const id of blessing) {
        if (!$gameParty.hasItem($dataItems[id])) {
            goods.push([0, id, 0]);
            break;
        }
    }
});

if (goods.length > 0) {
    SceneManager.push(Scene_Shop);
    SceneManager.prepareNextScene(goods, true);
} else {
    $gameMessage.setFaceImage('Actor3', 3);
    $gameMessage.setBackground(0);
    $gameMessage.setPositionType(2);
    $gameMessage.setSpeakerName('Ninshubur');
    $gameMessage.add('You have already received all of the Goddess\' blessings!');
    this.setWaitMode('message');
}
Ah, I see it now, I never removed the id placeholder.

Thank you for your help, everything is working now.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-change-shop-inventory-based-on-past-purchases.154875/