How to populate a variable on the cart with a select box
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 08:07 AM
EX:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 08:20 AM
Hi @Joshua Comeau Try below code
var categoryValue = current.u_category;
gs.info('Category Value: ' + categoryValue);
cart.setVariable(item, 'category', categoryValue);
Use gs.info() or gs.log() to debug the values and ensure that categortyValue is being set correctly and matches a choice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 08:26 AM
Did not work so I am using a scheduled job script to run to create and populate the cart.
that code did not even populate any or add a choice any idea?
Strings and reference fields work fine
but select boxes do not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 08:32 AM
Did this:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 08:28 AM
Hi @Joshua Comeau ,
Try the below:
var category = gs.info(current.u_category);
var getCategory = current.u_category.getDisplayValue();
cart.setVariable(item, 'category', getCategory);
Mark this as Helpful / Accept the Solution if this helps.