Data Hooks Help

For some reason my data hooks stopped working. I am not sure why. Basically, I have a form with a slideshow that changes based on the “Ad Size” selected in a Radio Group. In order for the slideshow to move when the Radio Group is selected, the values need to go in order like: 1, 2, 3, and 4 (I have four slides on this form). When the user submits the form I need the 1, 2, 3 and 4 to be converted to 9.5" x 12.5", 9.5" x 6.25", 4.75" x 6", and 4.75" x 3", respectively.

I have one more form that submits to the same dataset and is similar to the first form, but the Radio Group determines something else. So, the values don’t have to be 1, 2, 3, and 4.

The last form I have is most similar to the first form, but submits to another dataset, but I think that once I find the solution I will be able to figure this form out on my own.

Please offer any advice you have.

Link to my editor is here: https://editor.wix.com/html/editor/web/renderer/edit/4ff19054-25d2-487c-af5d-a3cf4c12204d?metaSiteId=022bb531-d4e5-46ba-a83b-1c4293a4a2d3&editorSessionId=4b4b337a-057c-4d59-9db6-383b377d07f5&referralInfo=my-account

Here’s the code for the hook (in the backend):

import wixData from 'wix-data';

export function Orders_beforeInsert(item, context) {
 //TODO: write your code here...
//print ad size
 let hookContext = context;
 
 if (item.adSize === '1') {
        item.adSize = '9.5" x 12.5"'
 
    } else if (item.adSize === '2') {
        item.adSize = '9.5" x 6.25"'
 
    } else if (item.adSize === '3') {
        item.adSize = '4.75" x 6"'
 
    } else if (item.adSize === '4') {
        item.adSize = '4.75" x 3"'
 
    } else if (item.adSize === '1.1') {
        item.adSize = '5.5" x 8.5"'

    } else if (item.adSize === '2.1') {
        item.adSize = '7" x 9.25"'

    } else if (item.adSize === '3.1') {
        item.adSize = '8.5" x 11"'
 
    }

 return item;

}

Okay, so awhile back I changed the name of the .js file and it stopped working. Now, I just changed it back and everything’s working now.

1 Like