Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Custom Field In Admin Order Details.tpl Rate Topic   - - - - -

 
  • Defgr
  • Newbie
  • Members
  • Join Date: 19-Feb 16
  • 5 posts

Posted 19 February 2016 - 11:19 PM #1

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:

 

Attached File  notes.jpg   64.84KB   5 downloads

 

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.



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11365 posts

Posted 20 February 2016 - 09:25 PM #2

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

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Defgr
  • Newbie
  • Members
  • Join Date: 19-Feb 16
  • 5 posts

Posted 22 February 2016 - 01:09 AM #3

This is the code of the field i use:

 <input class="input-small" type="text" size="45" value="{$oi.pnotes}" />

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.



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11365 posts

Posted 22 February 2016 - 09:20 PM #4

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]"


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Defgr
  • Newbie
  • Members
  • Join Date: 19-Feb 16
  • 5 posts

Posted 23 February 2016 - 12:29 AM #5

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

 <input class="input-small" type="text" size="45" name="order_info[extra][pnotes] value="{$oi.extra.pnotes}" />


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11365 posts

Posted 23 February 2016 - 01:20 AM #6

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.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Defgr
  • Newbie
  • Members
  • Join Date: 19-Feb 16
  • 5 posts

Posted 23 February 2016 - 12:19 PM #7

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.



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11365 posts

Posted 23 February 2016 - 07:12 PM #8

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.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • SunDust
  • Member
  • Trial users
  • Join Date: 13-Apr 16
  • 35 posts

Posted 10 October 2018 - 03:32 PM #9

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



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11365 posts

Posted 10 October 2018 - 06:44 PM #10

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.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19707 posts

Posted 11 October 2018 - 06:49 AM #11

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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.