Custom Field In Admin Order Details.tpl

Hello everybody.

I'm trying make a small customization in the order details.tpl. I want to be able to add a "note" for every product that is in an order.

I have added the column "notes" in cscart_order_details and also added an input field in the template as seen bellow:

[attachment=10825:notes.jpg]

What i want is to insert data in that column through the order details template if that is possible.

Any help is welcome, thanks in advance.

notes.jpg

Store your form data in the ‘extra’ array for each product in the cart.

This is the code of the field i use:

 

I'm struggling to understand how i should post the data of the input field in the "extra" array as tis stored as blob. Do i have to call a function or hook something else?

Thanks in advance.

Normally in cs-cart, arrays (and other complex data types) are serialized and stored as text in the DB.

In your input above, you have no 'name' attribute. You should use "order_info[extra][your_field_name]"

I did try the following code with no luck. The input is not inserted to the database :?

 

Do you have a pnotes field in the cscart_orders table?

If so, get rid of the 'extra' component and let it store it directly.

You'd mentioned blob data before.... Not sure you can use an input/text to deal with binary data.

Sorry, there's just not enough info on what you want to do and what you've done.

The system will save 'order_info' data directly to the cscart_orders table without doing anything other than creating the table column. However if you want to read it or see it in the UI (back or frontend) then you'll have to add that info to your templates and probably use php hooks for 'get_order_info_post' hook to retrieve it or the 'get_order_info_pre' hook and set the $fields variable to include your column name.

I added pnotes field in the cscart_order_details table as it is the only table i can see that has both order_id and product_code, because i want to store a "note" for each product that is an order.

I have manually added a value in the new pnotes field through phpmyadmin and i can show it in the backend orders details.tpl by using {if $oi.pnotes} which works fine if data is already in the field. I also have the input field as shown in the first post.

I have also tried

name="oi[pnotes]" 

for the input field with no luck. No data is saved in the db.

My problem is how to add/change the value that is in the cscart_order_details.pnotes field through the backend order details page.

There are no other fields I can think of where a user can affect the 'product' in a cart within checkout (other than the 'cart' mode). In this case you would use a name similar to cart_products[{$key}][p_notes]. Note that $key is the generated key for that product in the $cart['products'] array. But I'm not sure if it will update on its own if not in 'cart' mode. So in that case you might have to add a my_changes/controllers/frontend/checkout.pre.php handler that would look to see when this value is posted and then update the table.

Hello,

I want to change some information of right column of Order Detail screen (backend), so I modify the template: “design/backend/templates/views/orders/details.tpl” but nothing changes, why?? (I have cleaned the cache)

Thank you

What version are you running? Some prior versions have an addon for a newer responsive admin screen and the current versions have that now part of the core. So if that addon is active, you might have to make your changes in the addon templates versus the standard ones.

Strongly suggest you use hooks rather than modifying distributed files wherever possible.

If you use old admin panel on new CS-Cart versions, please edit the following file

design/backend/templates/addons/old_adminpanel/overrides/views/orders/details.tpl

And do not forget to clear cache