Custom Field validation?

  • Posts: 60
  • Thank you received: 1
  • Hikashop Business
1 month 2 weeks ago #315709

-- HikaShop version -- : 4.2.2
-- Joomla version -- : 3.9.15
-- PHP version -- : 7.2
-- Browser(s) name and version -- : Chrome

Hey,

So we have a custom database table with some data and we want to add a field to a product say 'Purchase Code' and when they try and add the product to the cart we want to validate that the code entered exists and has not been used. Is this possible? I can do it with custom ajax routine / script. But wondered what you think is the best way?

Also, same once order is complete I want to run a quick database routine? Suggestions?

Many thanks
Tony

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

  • Posts: 68480
  • Thank you received: 10205
  • MODERATOR
1 month 2 weeks ago #315710

Hi,

The best is to implement the onAfterProductQuantityCheck(&$product, &$wantedQuantity, &$quantity, &$cart_products, &$cart_product_id, &$displayErrors) trigger in a plugin of the group "hikashop".
This trigger will be called just before a product is added to the cart.
You can set $quantity to 0 to cancel the add to cart.

And for the order, I would recommend to do the same with the trigger onBeforeOrderCreate(&$order, &$do)
You can set $do to false to cancel the creation 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