Customising core functionality

Say you want to customise what happens after a user clicks on "Add to bag" button, we allow you to perform your own action using a function. This function has a pre-defined name as declared by our developers and all you need to do is use that function and define what it should do.

✍️ Objective - Display success message after Add to bag button is clicked

The name of the function which needs to be defined in order for an action to be performed after Add to bag event is called afterAddToBagCall

The function accepts 2 parameters productUUID and skuUUID

So, let's define the function

window.afterAddToBagCall = (productUUID, skuUUID) => {
    alert(`Add to bag button clicked`);
}

Let's add the above code snippet to our layout.js file. Once added, click on Save & preview store button.

On clicking the Add to bag (in this case Place in bag since we changed the text) button, we get a popup.

Once you click on OK the message disappears and your product is added to cart, as seen in the picture below.

This is how you can customise this function to do changes as per your requirement.

You can view list of all such custom Dukaan Functions here.

Last updated