I’m new to Velo but I really start to enjoying it.
Currently im having this issue because of a WIX update removing the Cart.AddCustomerItem() functions.
What I want to achieve is the following:
On the standard product page I would like to add a textbox next to the quantity. This textbox should only be shown in case of 2 (in the future maybe more) product ID’s.
I see the problem here, you did not adjust the fields from my first message, so ill just copy in the complete code:
$w ( ‘#dataset1’ ). onReady (()=>{ let currentItem = $w ( ‘#dataset1’ ). getCurrentItem (); let currentID = String ( ${ currentItem._id } ); if ( currentID === productId1 ){
$w ( ‘#text91’ ). text = “your text” ;
$w ( ‘#text91’ ). show ();
} else if ( currentID === productId2 ){
$w ( ‘#text91’ ). text = “your text 2” ;
$w ( ‘#text91’ ). show ();
} else $w ( ‘#text91’ ). hide ();
})
in your first message, you said you only want a certain text when specific products are displayed. You will have to paste the product ID from the Stores/Products collection into productId1 and productId2
Do you see “your text” or “your text 2”?
Can you put “console.log(currentID)” underneath let currentID = String (${ currentItem . _id }); and send a screenshot of what is logged in the console
Mhh okay, very strange. Try to use == instead of ===, maybe that works. If not put a console.log() with continous numbers inside each if statement, so we know if and where its stuck.
Thanks for your time again, really appreciate it. It think the problem is that it doesnt retrieve the right CurrentID. When adding the debuglog node it gives back another ID instead of the one i hardcoded :s
When I remove all other lines from the dataset and leave it with just the two I used hardcoding, it gives back always the same ID. Thats interesting… Do you have any ideas on how to make that current ID retrieve better?
$w ( ‘#dataset1’ ). onReady (()=>{
let currentItem = $w ( ‘#dataset1’ ). getCurrentItem (); let currentID = String (${ currentItem . _id });
console . log ( currentID ) if ( currentID == ( String ( ‘d66bea01c-c54d-400f-a1fc-565e8030bb96’ )))
{
$w ( ‘#text90’ ). text = “huurdagen1” ;
$w ( ‘#text90’ ). show ();
} else if ( currentID == ( String ( ‘d800b407-c1e0-4e74-b307-80466f9e3799’ )))
I would repeat what you said to see if I understood it right.
console.log(currentID) always returns the same ID independent on which product you are looking at but still the text if the if statement which is bound to this ID is not shown.
I unfortunately am not a pro and only can reference to what I learned building my website but what I would do next is at a
console . log ( currentItem )
To see if at least the selected item is the right one. And look if there the id is changing according to each item.