2

I have an object. But i don't know how to get the ID because it change for each page. So if make:

var obj = bundle.config.options

I get this result: https://i.sstatic.net/XHSPP.jpg

Then, i want to get in a var the number of the object -> '42' in this case

And then, i want to insert into the selection, and i hope it was like:

bundle.config.options[42].selections[314]

And then change the fields. Am i confused?

How could get this value?

UPDATE

I have associate by loop of other objets, the minQty of products for each product.

$minimumQty = $_selection->getStockItem()->getMinSaleQty();


                echo("<script>
                    var obj = bundle.config.options ;
                    var a = Object.keys(obj);

                    var keys = [];
                    for(var k in obj[a].selections) keys.push(k);


                    obj[a].selections[keys[d]].minQty = ".$minimumQty."
                      </script><br>");

The result -> each selection have the field: minQty with their number.

1 Answer 1

1

Try using Object.keys(obj), here is a link on how it is used.

OR

You can loop through you Object and get the keys

var keys = [];
for(var k in obj) keys.push(k);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.