Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8221917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:06:03+00:00 2026-06-07T14:06:03+00:00

I have defined some custom attributes and assigned them to products via the Opencart

  • 0

I have defined some custom attributes and assigned them to products via the Opencart admin panel. I’m trying to retrieve these attributes upon checkout to adjust some shipping costs.

I’m currently working in the catalog/model/shipping/ups.php file in the getQuote function. I’m getting close with this:

print_r($this->cart->getProducts());

Which gives me the following product data:

Array
(
    [59] => Array
        (
            [key] => 59
            [product_id] => 59
            [name] => My Product Name 
            [model] => ABC
            [shipping] => 1
            [image] => data/myproduct.jpg
            [option] => Array
                (
                )

            [download] => Array
                (
                )

            [quantity] => 1
            [minimum] => 1
            [subtract] => 1
            [stock] => 1
            [price] => 29.99
            [total] => 29.99
            [reward] => 0
            [points] => 0
            [tax_class_id] => 0
            [weight] => 3.75
            [weight_class_id] => 5
            [length] => 0.00
            [width] => 0.00
            [height] => 0.00
            [length_class_id] => 3
        )

)

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.

Usually I’d grep 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 :(.

EDIT

I believe Attributes are a newer feature that is built into Opencart. Its like a custom field.

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?

opencart product attributes

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T14:06:05+00:00Added an answer on June 7, 2026 at 2:06 pm

    Retrieve attributes for a given product_id

    $this->load->model('catalog/product');
    
    $attributes = $this->model_catalog_product->getProductAttributes(59); 
    
    print_r($attributes);
    

    Output

    Array
    (
        [0] => Array
            (
                [attribute_group_id] => 9
                [name] => Shipping Fields
                [attribute] => Array
                    (
                        [0] => Array
                            (
                                [attribute_id] => 16
                                [name] => Shipping Box Type
                                [text] => SM2
                            )
    
                    )
    
            )
    
    )
    

    Taking it further, here is an example of looping through the products currently in the cart to see what attributes they have:

    $this->load->model('catalog/product');
    
    $cart_products = $this->cart->getProducts();
    
    // get attributes for each product in the cart
    foreach($cart_products as $product) {
        $attributes = $this->model_catalog_product->getProductAttributes($product['product_id']);
        print_r($attributes);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some custom methods defined in my task model. I'm sending them into
I have defined some Error Messages and my Question is, how to access them
I have a few DependencyProperties defined in some custom user controls. I'd like for
I have some custom classes/modules defined under /app/lib . I have a Rake task,
I have custom control where i want to show some items. In generic.xaml defined
In express, I have defined some routes app.post(/api/v1/client, Client.create); app.get(/api/v1/client, Client.get); ... I have
I have a problem with Focusable Buttons on Eclipse Rap. I have defined some
I have defined a table type PL/SQL variable and added some data there. create
I have made a Java class where I have defined a constructor and some
I would like to export some macros that I have defined and be able

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.