title: How to retrieve custom attributes in Opencart?
body: <p>I have defined some custom attributes and assigned them to products via the <a href="http://www.opencart.com/" rel="noreferrer">Opencart</a> admin panel.  I'm trying to retrieve these attributes upon checkout to adjust some shipping costs.</p>
  
  <p>I'm currently working in the <code>catalog/model/shipping/ups.php</code> file in the <code>getQuote</code> function.  I'm getting close with this:</p>
  
  <pre><code>print_r($this-&gt;cart-&gt;getProducts());
  </code></pre>
  
  <p>Which gives me the following product data:</p>
  
  <pre><code>Array
  (
      [59] =&gt; Array
          (
              [key] =&gt; 59
              [product_id] =&gt; 59
              [name] =&gt; My Product Name 
              [model] =&gt; ABC
              [shipping] =&gt; 1
              [image] =&gt; data/myproduct.jpg
              [option] =&gt; Array
                  (
                  )
  
              [download] =&gt; Array
                  (
                  )
  
              [quantity] =&gt; 1
              [minimum] =&gt; 1
              [subtract] =&gt; 1
              [stock] =&gt; 1
              [price] =&gt; 29.99
              [total] =&gt; 29.99
              [reward] =&gt; 0
              [points] =&gt; 0
              [tax_class_id] =&gt; 0
              [weight] =&gt; 3.75
              [weight_class_id] =&gt; 5
              [length] =&gt; 0.00
              [width] =&gt; 0.00
              [height] =&gt; 0.00
              [length_class_id] =&gt; 3
          )
  
  )
  </code></pre>
  
  <p>However, no custom attributes are returned.  I'm sure there is a nice way to pass the product ID to an attribute-getting function, but I can't find it.  The Opencart docs are a little lacking for the development side and no luck on Google.  </p>
  
  <p>Usually I'd <code>grep</code> the hell out of the whole directory structure to find what I'm looking for, but shell access is disabled on this particular web host :(.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I believe Attributes are a newer feature that is built into Opencart.  Its like a custom field. </p>
  
  <p>Anyway, on the admin side I went to Catalog > Attributes and created a custom attribute called "Shipping Box Type".  Then, under a specific product I can set the attribute.  See screenshot.  My goal is to retrieve the value of "Shipping Box Type".  Does that answer your question @Cleverbot?  I'm sure I can do a custom db query to grab it, but theres got to be a built-in function to grab attributes?</p>
  
  <p><img src="https://i.stack.imgur.com/YhxzN.png" alt="opencart product attributes"></p>