Add Custom Field/s to Order Listing Table

  • Posts: 377
  • Thank you received: 7
11 years 6 days ago #137331

Hi,

I would like to add a custom field which is for start and expiry dates of the products that people have bought. I have created the custom fields, please see screen shot attached, and i am able to add the start and end date to the product which is great.

What i would like to do it include this in the order table so that the customer can login to their account and see the start and expiry date of the deals they have bought...

I have found the view of the orders listing but i am not sure what code i would use to include my custom field..?

Thanks

Alex

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
11 years 6 days ago #137347

This will be quite complex to do if you're not a developer as you need first to load the products of the orders with a MySQL query and a left join between the hikashop_order_product and the hikashop_product table. Once you have the list of products, you can add the column in the HTML but then, what about if you have several products for an order ?

Please Log in or Create an account to join the conversation.

  • Posts: 377
  • Thank you received: 7
11 years 6 days ago #137360

This is a very valid point. I hadn't thought about the layout of multiple orders.. Would it be possible to display it easily on the order page next to the product? Please see attached.

Thanks

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
11 years 6 days ago #137374

Then it's easier.

You can use such code:

<?php $productclass = hikashop_get('class.product'); $data = $productclass->get($product->product_id); echo $data->FIELD_COLUMN_NAME; ?>
after that code for example:
<?php echo $product->order_product_name; ?>
in the file "show" of the view "order".

Please Log in or Create an account to join the conversation.

  • Posts: 377
  • Thank you received: 7
11 years 4 days ago #137472

Thanks I shall give this a try. There is an odd error occurring after i have added the dates to the product, i then try to click back into the product and instead i get a 500 error page

500 - An error has occurred.
DateTime::__construct() [datetime.--construct]: Failed to parse time string (31/01/2014) at position 0 (3): Unexpected character

I cannot see anything else on the page apart from this. Do you know why it would do that?

Thanks

Alex

Please Log in or Create an account to join the conversation.

  • Posts: 377
  • Thank you received: 7
11 years 4 days ago #137473

I have just updated to the latest version of hikashop however it doesn't seem to have resolved this issue I will see if i can find anything on Google in the meantime.

Please Log in or Create an account to join the conversation.

  • Posts: 377
  • Thank you received: 7
11 years 4 days ago #137474

I tried to update the date format in the custom field to this %d%m-%Y- as this is how it was showing in the column in the products listing on the backend. I get the feeling this is a problem with the date format configuration somewhere?

Please Log in or Create an account to join the conversation.

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
11 years 3 days ago #137614

Yeah, the date format is quite sensible as the joomla calendar library doesn't handle all the possible cases.
You should clear the field of the product in the database via phpmyadmin and set back the default date format. That always works.
Otherwise, when you use another format make sure that you always have a character between each part of the date or the library won't be able to properly cut the date for the display of the calendar system.

Please Log in or Create an account to join the conversation.

  • Posts: 377
  • Thank you received: 7
10 years 11 months ago #138304

Hi Nicolas,

I deleted the value, then selected the date again using the date picker tool associated with the hikashop date field to choose the date, then again after saving it will not allow me to edit that product unless i unpublish the date fields. Am i supposed to be matching something up between the default joomla settings and that hikashop date field?

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
10 years 11 months ago #138370

Did you hange the date field format in between in order to use the default format that there is when you create a new date field ? Otherwise, of course, after you save the date with the unsupported date format, you'll still not be able to access the product.

Please Log in or Create an account to join the conversation.

Time to create page: 0.070 seconds
Powered by Kunena Forum