I need to modify the item price in the cart based ...
# ask-stanley-ai
z
I need to modify the item price in the cart based on the selection of transaction item options in NetSuite. Using scriptable cart we were able to modify the price on the sales order, but we also need to display the modified price on the SCA (SuiteCommerce Advanced) website. For example, if an item costs $100 and we include a transaction item option like "Room of Choice (+$50)," the cart should show $150
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that you can achieve your goal of modifying the item price in the cart based on the selection of transaction item options in NetSuite by using a combination of SuiteScript and workflows. Here's a possible approach: 1. Create a custom field on the item record to hold the additional cost for the "Room of Choice" option. This field will be updated via SuiteScript or manually when the item option is selected. 2. Use a User Event script to capture the selection of the "Room of Choice" option during the sales order creation process. When this option is selected, the script should update the sales order line with the additional cost. 3. To display the modified price on the SCA website, you can use a workflow. The workflow should be triggered when the sales order line is updated. It should then update a custom field on the sales order line with the new price (base price + additional cost). This custom field can be displayed on the SCA website. Here's a pseudo-code example of how the User Event script might look:
Copy code
javascript
function beforeSubmit(type){
    if(type == 'create' || type == 'edit'){
        var lineCount = nlapiGetLineItemCount('item');
        for(var i = 1; i <= lineCount; i++){
            var isRoomOfChoice = nlapiGetLineItemValue('item', 'custcol_room_of_choice', i);
            if(isRoomOfChoice == 'T'){
                var basePrice = nlapiGetLineItemValue('item', 'rate', i);
                var additionalCost = nlapiGetLineItemValue('item', 'custcol_additional_cost', i);
                var newPrice = parseFloat(basePrice) + parseFloat(additionalCost);
                nlapiSetLineItemValue('item', 'custcol_modified_price', i, newPrice);
            }
        }
    }
}
Please note that this is a simplified example and you may need to adjust it to fit your specific needs. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.832554638
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.831745
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823211074
Please provide your feedback on this answer.