Dukaan Themes
  • Introduction to Dukaan Themes
  • Building your own custom theme
  • Getting the basics right
  • Making your first edit
  • Theme folder structure
  • How does it all work?
  • Nunjucks Templating Language
  • Basic code editing
    • Adding the HTML
    • Adding the CSS
    • Adding the Javascript
    • Adding Nunjucks
  • Customising Dukaan Templates
  • Dukaan Data
  • Advance code editing
    • Customising core functionality
  • Dukaan Functions
  • Integrating Dukaan Plugins
    • Wishlist plugin
    • Countdown timer plugin
    • Product scarcity plugin
  • Testing and Deploying Your Theme
  • Code Snippets
    • Changing text of Add to bag button
    • Adding shadow to product cards
    • Adding auto-scrolling text in homepage
Powered by GitBook
On this page

Was this helpful?

  1. Advance code editing

Customising core functionality

PreviousAdvance code editingNextDukaan Functions

Last updated 2 years ago

Was this helpful?

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