简体   繁体   中英

NetSuite SCA Elbrus - Override PDP Module for Checking Quantity Available

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM