Change the visible field from False to True

import wixStoresBackend from ‘wix-stores-backend’ ;

async function updateFields ( prodId ) {
let product = await wixStoresBackend . updateProductFields ( prodId , {
visible : false

})

With this code running in the backend, I can successfully change a Wix Store product visible field to “false”. However changing “false” to “true” and rerunning the same code fails to revert back to true. I believe it fails because a false visible field makes the product inaccessible.

Does anyone know what I can do to make a product accessible so I can change the visible field back to “true”?

If I am doing this all wrong, appreciate your advice or help.

With only 8 viewers and no comments from Velo experts, I can only assume I asked a stupid question that did not deserve a response or dialog.

As a side comment, JavaScript is new to me since I never had any reason to learn it until early this year when I tackled, and still struggling, to build a website for my son’s new business. The needs of his site are not possible with “out of the box” Wix. Hence my use of Velo.

But I have two support complaints that I hope will not go on deaf ears. Not known as a complainer but trying to get Velo support here in the community forum is a struggle. Indeed, Wix Velo experts encourage learning Velo by writing here in the forum comments like “keep trying hard” and “we will help you by answering your questions”. This encourages people to go forward with their endeavor by using Velo. Unfortunately, at this point, such “help” has been a disappointment. The promised help comes in drips and drabs and often nothing at all. For example, a simple comment like “you can’t do this”, or “try this approach” to my above question would have been helpful. Instead, I waited days for nothing but “looks”. Further, I can see I am not alone since many searches turn up questions with no answers. Often, they plead for a comment. I empathize with those folks.

From years past, many questions brought on vigorous back and forth commentary. In fact, many of today’s online experts were just starting themselves back then with their questions and having good quality, thoughtful dialog with Wix support. But of late, support in the forum seems to have waned. Is that the true nature of support forums?

Having said that, Wix support is most disappointing of all. Having worked for many years at a software company that provided “on call” highest quality telephone support, Wix “Velo” support is nonexistent. With their 3 escalation gates, you must spend hours with the first two to get to the 3rd, who supplies only email support. At that stage, email support is not much value because by the time days or even weeks go by as you wait, you moved on to tackling other problems. It has been very frustrating to me since all my Wix questions are Velo related, and I have already spent hours searching for solutions on the web. And there is no way to jump the gates that I know of. My goodness, even Microsoft supplies helpful phone support and when they cannot they escalate at once.

I hope Wix reads this and makes it possible for fellow Velo programmers to get direct phone support at best or direct email support at worst. Without it, I genuinely believe many budding Velo programmers will fall by the wayside and move on to other popular programmable systems.

Hi Break80,
Thanks for sharing your feedback. To help set expectations:

  • Please keep in mind that this is a community forum (members helping members), not Wix Support, so we can’t guarantee that your questions will be answered (see our comment about this here ). When it takes a while to get a response, it could mean that other members are busy, or they may not know the answer.

  • In terms of Wix Support for Velo, our agents are only trained to discuss the capabilities of the platform and to debug Wix functionality, not answer coding questions.

I will share your feedback with the team and see what more we can do to improve your experience in the Velo Forum.

Thanks for the feedback Marlowe. I do appreciate your getting back to me.

I understand perfectly about it being a community forum and all that entails…I used to be involved in one a very long time ago, in the early days. Maybe I am wrong, but I believe dialog activity several years ago was a lot more vigorous that these days. Maybe there are fewer members due to Covid…hmmm…I had not thought of that until now. In any case I do find those old discussions very useful as I know others do as well.

Re your second comment, all my questions are related to my coding with Velo…I have not asked anything related to other languages. That is why I place them in the velo coding section of the forum. I am not a professional so I do not push them into the professional forum. Rest assured I do always thoroughly research my questions and use the forum as a last resort. I search this forum, other wix related forums and in JavaScript forums since the two are so closely related, and also do testing using the Wix interface, all BEFORE asking them. Sometimes I take the extremely frustrating step of trying to communicate with the Velo team at Wix but so far that has never been fruitful.

Overall I have learned a lot about Wix, Velo, Javascript and building websites using code in the past few months. I could not have done that without looking back into the old forum discussions. So I am not completely unhappy, I only wished the Wix company techies would get engaged as they seem to have in the past.

I tried this out myself and it works fine.

This is the function in the backend (.jsw file):

export async function updateProductVisiblity(prodId, visible) {
   let product = await wixStoresBackend.updateProductFields(prodId, {
      visible: visible
   })
}

I call the function from my frontend code as follows:

set to not visible

 await updateProductVisiblity(prodId, false);

set to visible

 await updateProductVisiblity(prodId, true);

When the product is set to not visible, it does not appear in the Stores/Products collection, and does not appear in the Products gallery. When I set it back to visible, the product once again appears in the Stores/Products collection, and is displayed in the Products gallery.

Thanks for this. I am not getting this to work. I tried it with a group of products.

I copied the id’s from the database to be sure I have the correct ones. When the products are set to not visible (false), they still appear in the Products gallery page. However when I manually refresh the page they do not appear.

The opposite is also true. When I set them back to visible (true), they still do not appear. However when I manually refresh the page, the products once again appear in the Products gallery page.

You did not mention in your comment so I assume this anomaly is not happening with your test. What am I doing wrong?

@jimyaccino Just setting the visible state won’t affect the gallery contents that are displayed on the page. You will need to force a refresh of the page in code to ensure that the updates are reflected in the displayed content.

While I waited for your response, I tried and tried to do what you suggested but failed. I built code to refresh the database and that did not solve the problem. So I tried diligently in code to refresh the page but failed after multiple attempts to figure out what code I needed for that. Nothing worked for me. So, I gave up and switched methods to what seems to me simpler and no real coding changes. I set up a smaller set of collections with the products I wanted visible on that single page, and a larger set of collections for all other products for all other pages. That worked and I have confidence it will always work.

If you have some example on how to refresh a page, please can I see it. Later I may need to return to the visible approach, which is more elegant I think.

A simple way to refresh the page would be like this:

wixLocation.to(wixLocation.url);

Make sure you have the import statement at the top of your code file:

import wixLocation from 'wix-location';