I am looking to add a coverage service to my products on my Suite Commerce Advanced Store.
Scenario: A customer visits the product page, they like the item they want, but they also want to add additional coverage.
My idea is that if the customer checks the box, then I can somehow edit the the add-to-cart function to include the service item's Internal ID.
HTML
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="addwarranty" name="darkmode" value="yes">
<label class="form-check-label" for="addwarranty"><strong>Add Warranty!</strong> <a href="#" target="_blank">Learn more</a></label>
</div>
JS
var wntid = "123456";
$('#addwarranty').change(function(){
if (this.checked) {
//alert('warranty checked');
// Update add-to-cart event to include wntid
}
});
I looked in the shopping.js file, but it only has the event and not the function.
Is there another JS file I should be looking at? Is there a way I can get this from the web developer console?
Unless this is a legacy version of SCA, you should use the extensibility layer to achieve this.
You need to download the developer tools, create an extension and add your code.
The method you are looking at is the "addLines" from the Cart Component. https://system.netsuite.com/help/helpcenter/en_US/APIs/SuiteCommerce/Extensibility/Frontend/Cart.html#addLines
The following link contains information about the extensibility layer and how to set up the dev tools.