title: Opencart - get product option quantity or stock text (option to product module)
body: <p>I am using Option to Product extension on my Opencart 2.0x website. It all works as expected. I want to have the stock availability of the options in the option select box. For example:</p>
  
  <p>Current: <br>
  Blue <br>
  Red<br>
  Orange</p>
  
  <p>What I want:<br>
  Blue (In Stock)<br>
  Red (In Stock)<br>
  Orange (Out of Stock)<br></p>
  
  <p>Something like the above. So I need to either get the stock text or the quantity and then manually add the text dependant on the quantity.</p>
  
  <p>I try to modify the code in view/theme/*/template/product/product.tpl to be:</p>
  
  <pre><code>&lt;?php 
  foreach ($option['option_value'] as $option_value) {  
  if ($option_value['quantity'] == "0") {
  $stock = "Out of Stock";
  } else {
  $stock = "In Stock";
  }
  ?&gt;
  &lt;option value="&lt;?php echo $option_value['option_value_id']; ?&gt;"&gt;&lt;?php echo $option_value['name']; ?&gt; (&lt;?php echo $stock ?&gt;) &lt;/option&gt;
  }
  </code></pre>
  
  <p>In catalog/controller/product/product.php after </p>
  
  <pre><code>'option_value_id'         =&gt; $option_value['option_value_id'],
  </code></pre>
  
  <p>I add</p>
  
  <pre><code>'quantity'         =&gt; $option_value['quantity'],
  </code></pre>
  
  <p>I get nothing!</p>
  
  <hr>
  
  <p>I have even tried to access the database directly but it doesn't work - I am not sure how to get the value I want from the database - I use</p>
  
  <pre><code>$product_id = $product_id;
  $option_id = $option_value['option_value_id'];
  
  $get_otp_id = $this-&gt;db-&gt;query("SELECT id from oc_otp_option_value where product_id = $product_id AND parent_option_value_id = $option_id");
  </code></pre>
  
  <p>I know I cannot add this to the product template page as it is a MVC setup but don't know how to add this to the Model and then use the Controller to get the data and show it on the View template as I am a noob with MVC and OpenCart.</p>
  
  <p>Please help - I will love you forever!</p>
  
  <p>Thanks</p>