How to Add Addresses in SuiteCommerce 2.x

in , , December 31st, 2024
a close up of a keyboard on a laptop

Adding addresses is a common task to be completed for a SuiteCommerce website and is quite easy once you know how to do it!

Code Example: Add Addresses in SuiteCommerce

See the code example below.

/**
 * @param {Record Object} customer
 * @param {object} address
 */
function updateAddress(customer, address) {
    var currentAddressCount = customer.getLineCount({
        sublistId: "addressbook",
    });
    //either select a new line or select the desired line
    if (currentAddressCount === 0) {
        customer.selectNewLine({
            sublistId: "addressbook",
        });
    } else {
        customer.selectLine({
            sublistId: "addressbook",
            line: 0,
        });
    }
    //get the address subrecord
    var addressSubrecord = customer.getCurrentSublistSubrecord({
        sublistId: "addressbook",
        fieldId: "addressbookaddress",
    });
    // Set all required values here.
    addressSubrecord.setValue({
        fieldId: "addr1",
        value: address.line_one,
    });
    //commit the line, and don't forget to save!
    customer.commitLine({
        sublistId: "addressbook",
    });
    customer.save();
}

Author: Sam Gagliardi

Got stuck on a step in this article?

We like to update our blogs and articles to make sure they help resolve any troubleshooting difficulties you are having. Sometimes, there is a related feature to enable or a field to fill out that we miss during the instructions. If this article didn't resolve the issue, please use the chat and let us know so that we can update this article!


FREE SuiteCommerce Book

If you liked this article, you'll LOVE our book on SuiteCommerce! Order the free SuiteCommerce book today, and we'll even pay for shipping!

Oracle NetSuite Alliance Partner & Commerce Partner

If you have general questions about SuiteCommerce or more specific questions about how our team can support your business as you implement NetSuite or SuiteCommerce, feel free to contact us anytime. Anchor Group is a certified Oracle NetSuite Alliance Partner and Commerce Partner equipped to handle all kinds of NetSuite and SuiteCommerce projects, large or small!

We are a premium SuiteCommerce agency that creates powerful customer portals. Unlike our competitors, we have already solved your problems.

 
 

Want to keep learning?

Our team of NetSuite and ecommerce professionals has written articles on a wide variety of topics, from step-by-step tutorials, to solution recommendations, available support services, and more!

Your cart