How to edit label text in Wix Code?

Hi all. I’m trying to do something that is probably very easy, but I can’t figure out how.

I’m helping build an e-commerce site, and we have a need to change our product pages so that the Quantity field says something else. The standard editor does not appear to allow this, so I thought that this should be doable with Wix Code. I was thinking that I could write JavaScript to find the element that holds the quantity text and change its inner text.

Looking at the output HTML of the page, this appears to be a label tag; something like:

<label class="label quantity-label" translate="QUANTITY_LABEL" data-hook="number-input-spinner-title" for="quantity-input">Quantity</label>

However, I can’t figure out how to use Wix Code to pick out label elements. It also appears that trying to traverse the DOM w/o using the Wix Code API will not work either. I’m probably missing something simple. Any help would be appreciated.

Thanks.

WixCode doesn’t use labels??
the ID is found in the elements Properties in the editor.
the code to change text for a Text element is

$w('#elementID').text = string


Unless the page is on an HTML element embedded?

Thanks for the reply, Ethan. That information should be helpful, but I still can’t figure it out. Selecting an element by ID was going to be my initial (and obvious) approach. However, the Properties panel doesn’t let me select elements below the Product Page hierarchy - i.e., productPage1 is the lowest that it will display properties for. Hence my attempt to select by type. Is there something that I should change in order to be able to view properties for subelements?

I am very confused.
Are your objects grouped together or are they in an HTML Embed element??

I am, too…haha. I guess the answer is that they are grouped together? Basically, we are using a Product Page template that has various settings (layout, displayed options, etc.). But this appears in the editor as one grouped item with ID productPage1. Among the optional items that are displayable using this template is Quantity; we want to kinda repurpose this with a different displayed text label. It seems that the editor does not allow picking out the subelements of this single templated object. And there don’t appear to be any options to relabel the available fields.

click once on the group then move your cursor over the text

Unfortunately, it’s not a group of elements like that. It seems to be just a blob from a code point of view. I do see that the type is $w.iFrame, though.

Anyway, thanks for the help.

Hi,

I’m Netalee from Wix Stores- hope i’ll be able to help.
Not sure i understand what you’re trying to do - what should appear in the qty field?

In general, if you want to use the native product page and to change things on top of it (rather than building from scratch) you can use ‘Get Product’ API to get the current product.

In the Product Page settings inside the Editor you can set it not to display the qty and add to cart button
https://cl.ly/5f7daebaa563

This way you can create you own qty and add to cart button (using ‘Add to cart’ api)

Thanks

Hi, I’m trying to do something similar to this thread. As my product is sold per metre, I would like the ‘Quantity’ to read ‘Quantity (metres)’. Like the person above I have searched for the elementID but can’t track it down. I’d rather not have to attempt to write a whole new quantity input if possible. Would it be possible to give me the elementID or tell me how to find it?

Thanks for any help in advance.