I am trying to modify an item, so that only some o...
# suitecommerce
b
I am trying to modify an item, so that only some of the options are shown. Is there a way to modify if an item option is available using this function?
Copy code
layout.addToViewContextDefinition('ProductDetails.Full.View', 'isAvailable', 'boolean', function (context) {
					console.log("OPTIONS CONTEXT",context);
					return false;
		    	});
s
Stepping back, what's the use case here? Why do you want to hide an item option? Is it only for a particular item or particular types or all items?
b
We are selling nametags to a church for their missionaries. We offer tags in several languages, and have a list of available languages. We are now going to offer service missionary tags, but the list of available languages is smaller. I want to know how to filter the list down, without having to make a new list and if possible without modifying the DOM.
We do some backend logic with a 3rd party that makes the tags, so a different list with new internal IDs would cause a lot of issues. There are alot of aspects of our process I can explain if needed. But I want to know if its possible to filter the list of options without using Jquery later (Ive already figured out how to do that)
I can see the data in the PDP object, Im just not sure if it can be modified.
s
OK, that’s interesting. And this is an SC site or an SCA site?
b
SCA
s
OK, well the path is (in the latest version) /SC_23.2_Live/Commons/ProductViews/JavaScript/ProductViews.Option.View.ts — the getContext() function is what generates that array of objects
I would think that the best to filter the values is at this point, if you can’t/won’t change them in NetSuite
If the list of languages is fixed then you could hardcode them into this view such that it checks whether the cartOptionId is custcol_byu_name_tag_language and if it is, runs a filter() on them to narrow down the list
Ideally, I think it would be better to fetch the list of acceptable languages from the config file, so that it can be updated later if things change
b
Ok, I will look into the config file. Thank you
s
I mean, you would have to write a customisation to add a field to the config file
So that business users can enter their list of acceptable languages
Then your code customisation fetches that list before filtering
b
We already have a customization for some other aspects, the language filtering is new.
How do I access teh config values from SC.Environment
s
You shouldn’t really call the
SC
global variable in your code, but the config values will be present from the Configuration module, which is already included as a dependency in this module. So you would just call
Configuration