Jump to content

Display product custom field on order history list


Daniel Patilea

Recommended Posts

Hello,

 

Is there any way i can add a custom product field to the table from the order history in the customers account?

 

I already added {$product.shipping_date} in the order-detail.tpl file but it won't display anything.

The custom product field is working great if i use it elsewhere.

 

Here's a debug view of the $product variable: http://i.imgur.com/SqjImiE.png

 

Here's a screenshot:

W6ajraD.png

 

Can anybody help me please?

Link to comment
Share on other sites

  • 2 weeks later...

I think it's not retrieving it. Have a look at OrderDetailController

$products = $order->getProducts();

It uses this method, so I think you have to modify Order::getProducts so it gets the correct column from the DB

  • Like 1
Link to comment
Share on other sites

I think it's not retrieving it. Have a look at OrderDetailController

 

$products = $order->getProducts();

 

It uses this method, so I think you have to modify Order::getProducts so it gets the correct column from the DB

 

Thanks Nemo,

I added the custom field in the query list and it works perfectly.

One more question, how can I display this custom field on the order email that the client receives after he places the order?

Link to comment
Share on other sites

Cool!

That's another story, PaymentModule.php, ValidateOrder method :)

I have edited this file: /classes/PaymentModule.php and added my custom field:

                       $product_var_tpl = array(
                            'reference' => $product['reference'],
                            'shipping' => $product['custom_field'],
                            'name' => $product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : ''),
                            'unit_price' => Tools::displayPrice($product_price, $this->context->currency, false),
                            'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
                            'quantity' => $product['quantity'],
                            'customization' => array()
                        );

Then i tried to add it to the email template (not sure this is the correct file) editing this file: /mails/en/order_conf_product_list.tpl

            <tr>
                <td width="10"> </td>
                <td>
                    <font size="2" face="Open-sans, sans-serif" color="#555454">
                        {$product['reference']}
                    </font>
                    <p>{$product['shipping']}</p>
                </td>
                <td width="10"> </td>
            </tr>

But it doesn't show anything in the email.

Can you tell what seems to be the problem please?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...