Extension to show available quantity in checkout page

_.extend(TransactionLineViewsCellNavigableView.prototype, {
	  getContext: _.wrap(TransactionLineViewsCellNavigableView.prototype.getContext, function (fn) {
	      var context=fn.apply(this, _.toArray(arguments).slice(1));
	      
	      var url=window.location.href;

	       if (url.indexOf("review") > -1) {
	        context.availablequantity=context.model.attributes.item.attributes.quantityavailable;
	        context.showavailablequantity=true;
	        $("#available").css('display', "block");
	      }

	      return context;
	    })
transaction_line_views_cell_navigable.tpl code:

{{#if showavailablequantity}} 
<td class="transaction-line-views-cell-navigable-item-quantity" name="item-a-quantity" id="available"> 
<p> 
<span class="transaction-line-views-cell-navigable-item-quantity-label">{{translate 'Available Quantity:'}} </span> 
<span class="transaction-line-views-cell-navigable-item-quantity-value">{{availablequantity}}</span> 
</p> 
</td> 
{{/if}} 

Leave a comment

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