0

I am new to SuiteCommerce Advanced development and I would like to override a module from the Product Details Page.

The goal is to add a "max" attribute to the 'Quantity' input for products and the max attribute value will be set to the quantityAvailable for the current product being viewed. The reason is I want to prevent the user from adding more than what is currently available to their cart.

I am guessing that I need to override the core ProductDetails module and override the ProductDetails.Quantity.View.js file.

My thinking would be to just add a condition in the 'setQuantity' and 'setFocus' methods to check the quantity available for the item, but I don't know where to start in order to pull this data into the module.

Does anyone have any ideas? Currently on SCA Elbrus.

coopwatts
  • 670
  • 1
  • 8
  • 31

1 Answers1

0

You can create an event, or use an existing event for when the increment arrow is clicked, and test to see if the limit has been reached, preventDefault if it's limit is reached, or return true otherwise.

Also, you shouldn't be overwriting / altering the core files. Best practice is to create an extension. The SCA developers website describes this pretty good using howto guides now.

http://developers.suitecommerce.com/

Hope this helps, thanks.

Gareth
  • 92
  • 8
  • I did end up using the extensibility API for this. Although versions Elbrus and prior are limited in the extension capability. I would never modify a core file, but I would create a new module that would override the core file. – coopwatts Oct 04 '18 at 20:18
  • @coopwatts can you please please please tell me how to do that? That would help me A TON. Please Help – aditya rawat Feb 02 '21 at 10:12
  • @gatty if you can please help me as well – aditya rawat Feb 02 '21 at 10:54