afterAdd Event

arguments:

  • item: evoShop.Item that was just added to the cart
  • isNew: boolean of whether the item is a new item to the cart, or was already there and simply incremented the quantity
  • The ‘afterAdd’ event is triggered immediately after an item has been added to the cart. You can modify the item using the reference.

    // basic callback example
    evoShop.bind( "afterAdd" , function( item ){
      console.log( item.get("name") + " was added to the cart!" );
    });
    
    // see if a new item has been added
    evoShop.bind( "afterAdd" , function( item , isNew ){
      if( isNew ){
        console.log( "A brand new item called " + item.get( 'name' ) + " was added to the cart" );
      }
    });
    
    // modify the items price based on weight
    evoShop.bind( "afterAdd" , function( item , isNew ){
      if( item.get( 'weight' ) > 10 ){
        item.price( 20 );
      } else {
        item.price( 15 );
      }
    });