Sunday, May 12, 2019

Scriptable Cart & Checkout: Set the Maximum Order Quantity for an Item


At the moment it is possible to set the minimum order quantity for an item. However there is no option to set the maximum order quantity of an item. To set the maximum order quantity scriptable cart can be used on the web store. The logic will be to add a custom field in the item record and enter a value for the maximum quantity. Then the quantity value of a line item in a sales order can be compared to the custom field's value to determine if that exceeded the maximum order quantity. Follow the steps below to achieve this:

1. Setup > Customization > Item Field > New

2. Label the field, select the type as Integer Number and apply it to Inventory item

3. Display it at the main section and Save

4. Create a Client Side Script

5. Use the following code for the script

[Note: For this example inventory item with the internal id 6 is used. To make it dynamic, get the line item count for the sales order and then sort through each item accordingly. Also custitem26 is the internal id of the custom field]

6. To use this validation on the web store, Scriptable Cart has to be used

7. Enable the scriptable cart by navigating to Setup > Site Builder > Setup Web Site > General tab > Preferences section check Scriptable Cart and Checkout

8. Make sure the script is deployed at the form level by navigating to Setup > Customization > Transaction Forms > Edit the form used for the Sales Orders

9. Once in the edit mode for the transaction form click the Custom Code tab and attach the script file created in step 5

10. Also call the function 'validateqty' for the Validate Line Function

11. Finally navigate to Setup > Site Builder > Setup Web Site > Shopping sub tab

12. Select the transaction form for both Credit Card Form and Invoice Form under the Checkout Preferences section

No comments:

Post a Comment