How to question: Resetting custom-fields to blank when client reorders

  • Posts: 62
  • Thank you received: 1
7 years 4 months ago #273072

-- HikaShop version -- : 3.1.1
-- Joomla version -- : 3.7.2
-- PHP version -- : 7.0.19
-- Browser(s) name and version -- : Chrome
-- Error-message(debug-mod must be tuned on) -- : none

Hello,

I have a webshop where I added a custom field to the items table so a vendor can store a weight-value for each item in an order.

In this thread:
www.hikashop.com/forum/orders-management...r-functionality.html
I read and understood that if you reorder, the custom fields automatically are taken over in the new to be created order. Can I let Hikashop reset these value's automatically?

I guess I would need to create a plugin with the onAfterOrderCreate trigger and there empty the values manually? Would it be sufficient to unset the particular variables or should I give them an empty (string) value, or null?

Kind regards,
Teeuwis

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

  • Posts: 82864
  • Thank you received: 13372
  • MODERATOR
7 years 4 months ago #273084

Hi,

When you click on the "reorder" button, what happens is that the products from the order are added to the cart.
So you would have to actually implement the onBeforeCartSave(&$element, &$do) trigger in order to remove the custom item fields values from $element->products (with an unset).
In the trigger of your plugin, you can easily know if the customer is currently reordering by having a check like that:

if($_REQUEST['task']!='reorder') return;

Because with a trigger like onAfterOrderCreate, it's much more complex as you're not sure that the customer is coming from a reorder, and you have to write MySQL queries to empty the custom item fields of the products of the order.

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

Time to create page: 0.052 seconds
Powered by Kunena Forum