jeudi 30 septembre 2021

JS Conditional statement

Hi in the below code the e.price is the price of a product, i want to know how i can put If conditional statement in this so that price with price 0 shall not be show(no price),and if amount is greater then 0 then it will be show. I tried if(e.price == 0) but i dont know how and in which line it should be written. Thanks in advance

formatResult: function(e, a) {
  var i = "(" + (a = "&" === a ? "&" : a).replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + ")",
    a = "";
  return (
    e.divider && (a += ' <h5 class="search-divider-text">' + e.divider + "</h5>"),
    e.thumbnail && (a += ' <div class="search-thumb">' + e.thumbnail + "</div>"),
    e.value && (a += '<h4 class="search-title">' + e.value.replace(new RegExp(i, "gi"), "<strong>$1</strong>").replace(/&lt;(\/?strong)&gt;/g, "<$1>") + "</h4>"),
    e.no_found && (a = '<div class="no-result">' + e.value + "</div>"),
    e.view_all_products && (a = '<div class="view-all-products"></div>'),
    e.sku && (a += ' <div class="search-sku">' + e.sku + "</div>"),
    e.price && (a += ' <div class="search-price">' + e.price + "</div>"),
    a
  );
},

Aucun commentaire:

Enregistrer un commentaire