Sorry for the delay here. The issue is that "state" is the
only thing that's passed between operations. (It's also passed between job runs if you've got multiple jobs chained using flow triggers, or if you've got a timer job—in which case each run will inherit the final state of the last run.)
If you want to define a constant during a setup operation using alterState (which is a common pattern) you've got to "hang it on state" like this:
alterState(state => {
state.cartId = state.data.Envelope.Body.notifications.Notification.sObject.Id;
return state;
});
query(`SELECT Id, ccrz__Price__c FROM ccrz__E_CartItem__c WHERE ccrz__Cart__c = '${state.cartId}'`);