Working with setQuantity() in a child view of the ...
# suitecommerce
k
Working with setQuantity() in a child view of the pdp without any luck. The documentation is pretty thin….does this even work? Or should I just play around with the quantity parameter?
😪 1
s
It works just fine AFAIK. One thing that can catch people out is sending it a quantity as a string rather than an integer. For example, if you're passing in a value from a custom record or configuration, then make sure you run
parseInt
on the value.
If that doesn't work, could you tell me which version you are working on
k
Hi Steve - working in 2019.1
I believe I set the value as an integer
it should be setQuantity(integer) right?
I have an event that triggers a function and this is in the function….
ok - soo…..I had an interger (I thought) but added parseInt and it works (I think)
s
🤨
SC.Application('Shopping').getComponent('PDP').setQuantity(5) should work in your browser console
it should immediately change the value on the form to 5
k
Heh heh no complaints as it seems to work! Trying to now keep change some context based on the event….do you think the best way is to re-render the view
s
If you're putting setQuantity in your code, you'll likely need to wrap in an event, such as beforeShowContent/afterShowContent.
And yeah if you change a template's context after it has been rendered, you'll need to re-render it
Context is essentially an options object sent to a constructor. If it's already been constructed, then you'll need to reconstruct it
k
ok - that makes sense - re-rendering works….of course it brings up other isse but I can at least start down that road
thanks for your help
fyi - I’m adding custom events that trigger the setQuantity
s
then you should be gucci
😎 1