Can I check the Quantity Select Box value from a client script?

cfraser
Tera Contributor

Hello,

 

I would like to check the value of the quantity selector box on a catalog item page. How can I access this value in a client script? Screenshot attached below. 

cfraser_0-1711982199850.png

Thank you.

1 ACCEPTED SOLUTION

ajit kasabale
Tera Expert

Hello ,

You can get it in client script; you just have to update the script mentioned below .
You have to make the changes in the function c.updateQuantity and you have to use c.quantity to get the selected value 

Need To Change :

Script.PNG


OutPut: 
Quantity.PNG
Mark It Correct If it's helpful

View solution in original post

4 REPLIES 4

g k1
Tera Guru

can u tell what u actually need to do?

swathisarang98
Giga Sage
Giga Sage

Hi @cfraser ,

 

You can access the field with backend name as "quantity"  for example i created a onload client script and added the quantity in the alert so could you please tell what is your exact requirement like what you want to do with the quantity value ?

swathisarang98_0-1712094239090.png

Client script:

swathisarang98_2-1712094370852.png

 

 

function onLoad() {
  var quantity = g_form.getValue('quantity');
   alert("Quantity is : "+ quantity);
   
}

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

-O-
Kilo Patron
Kilo Patron

This will work only on stand-alone Catalog Items (not Order Guides) and if the OOB Catalog Item widget structure is in place:

function onChange (control, oldValue, newValue, isLoading) {
	var scope = top.angular.element('[id="sc_cat_item"]').scope();
	var quantity = scope.c.quantity;
	alert(quantity);
}

I'm showcasing an onChange Catalog Client script, but other types will work the same.

ajit kasabale
Tera Expert

Hello ,

You can get it in client script; you just have to update the script mentioned below .
You have to make the changes in the function c.updateQuantity and you have to use c.quantity to get the selected value 

Need To Change :

Script.PNG


OutPut: 
Quantity.PNG
Mark It Correct If it's helpful