Out-of-stock notification

Need to show one field form whenever an item is out of stock. And the form contains email input with notify button. Then the email needs to pass to listrak. 

Form sample template 
<form class="focused-form-view"> 
  <fieldset> 
    <span class="out-stock-notification-main-heading"> Be the first to know. Get an email when this item is back in 
      stock. </span> 
    <div class="pdp-out-email-container"> 
      <div class="pdp-out-email-title"> 
        <span> Email Address </span>
        <input id="bis-email" class="stocknotifications-subscribe-input" type="email" name="email" value="" 
          placeholder="your@email.com" required> 
        <div><small class="warningmessage"></small></div> 
      </div> 
      <div class="stock-success-message-noti"> 
        <a class="stocknotifications-pdp-out-button" data-action="out-stock-notification"> 
          {{translate 'Get notified'}} 
        </a> 
      </div> 
      <div><small class="warningmessageout "></small></div> 
    </div> 
  </fieldset> 
</form> 

For getting the out-of-stock item 

  this.pdp = options.PDP; 
      var item = this.getItem(this.pdp); 
      var self = this; 
      this.outofstock = this.isOutofStock(item);

For matrix item 

      this.pdp.on("afterOptionSelection", function () { 
        item = self.getItem(self.pdp); 
        self.outofstock = self.isOutofStock(item); 
        self.render(); 
      }); 

Email validation 

      function validateEmail(email) { 
        // RFC 5322 Official Standard - https://emailregex.com 
        let re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 
        return re.test(email); 
      } 

Leave a comment

Your email address will not be published. Required fields are marked *