Update Value from Product data to Order Product Data

  • Posts: 6
  • Thank you received: 0
  • Hikamarket Multivendor Hikashop Business
6 months 3 weeks ago #272705

Hello, I am trying to setup mass actions to take a value from a custom field in the product table and save it with the order product data in the Order_Product table. I have created a custom field called "order_product_case_size" under the option for table = "item" and I can see the column in the database in the right table. Below is the screenshot of my mass action settings (which I am sure are not right).



How can I accomplish this? If there is no built in solution, I would love a work around. Maybe there should be a massaction plugin for order_product?

Thank You.

Attachments:

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

  • Posts: 60551
  • Thank you received: 8534
  • MODERATOR
6 months 3 weeks ago #272707

Hi,

There are 2 problems with your mass action:
1. the "after an order is created" trigger is after the order is created, but before the insertion of the products of the order in the order_product table.
2. there is no product.unitspercase tag you can use there. The only column tags you can use are the columns listed in the first dropdown and custom product fields are not listed there.

So it won't be possible with a mass action.
The only proper way to do this would be to create a small plugin impelmenting the onAfterOrderCreate trigger and setting the value yourself in the plugin.

As a trick, if you have a column with the same name in the hikashop_product table as you custom item field and that you display the custom item field on the product page (you can hide it in CSS and it will still work) the system will automaticaly copy the value from the column in the hikashop_product table to your custom item field in the cart and then the order.
You can then potentially have a mass action to copy the value from your unitspercase custom product field column to the column order_product_case_size with a product mass action when you create/update a product.
That way, you can still edit the value in the backend interface and have it synchronized in the column of the hikashop_product table.
That's the only solution I see without any coding.

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

  • Posts: 6
  • Thank you received: 0
  • Hikamarket Multivendor Hikashop Business
6 months 3 weeks ago #272712

Thank you! I made a plugin to do the trick. I attached it here in case its helpful or in case you have time to review it you can tell me if its okay or if I did it the wrong way, the end result is that it works.

Attachments:

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

  • Posts: 60551
  • Thank you received: 8534
  • MODERATOR
6 months 3 weeks ago #272720

Hi,

That looks good yes. I would just recommend removing the echo lines so that they don't display to the customer, but I suppose you already know that :)

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

Time to create page: 0.086 seconds
Powered by Kunena Forum