Post Text transform for customer input at checkout

  • Posts: 317
  • Thank you received: 17
  • Hikashop Business
5 years 9 months ago #303419

-- HikaShop version -- : 4.0.1
-- Joomla version -- : 3.9.2
-- PHP version -- : 7.2

Hi
I need to get all customer input at checkout in uppercase. So if customer fill in with lower or uppercase, data is allways uppercase saved.

I know for regular expression field option, but as I can understand, if customer write lowercase, then warning is shown and that is not what we need.
So auto transform input.

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
5 years 9 months ago #303422

Hi,

There is no option for that. You would have to write a small plugin to change the case when the data is being saved thanks to the triggers available:
www.hikashop.com/support/documentation/6...r-documentation.html

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

  • Posts: 317
  • Thank you received: 17
  • Hikashop Business
5 years 9 months ago #303469

What about some custom overide for fields like
<input oninput="this.value = this.value.toUpperCase()" />
will this work?

Im not so good in php to write plugin.

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
5 years 9 months ago #303478

Hi,

Creating a Joomla plugin is not complex. You can find tutorials on that:
docs.joomla.org/J3.x:Creating_a_Plugin_for_Joomla
It doesn't require particular coding skills. Just create the XML and PHP files are indicated in the tutorial and replace the different pieces based on your situation.
Once you know how to create a joomla plugin, you just have to replace the <EventName> of the plugin by the trigger name form our developer documentation for the data element you want to change.
For example, if it's a custom order field, it's the onBeforeOrderCreate trigger you want to implement.
Then, in the code of the function, it's similarily one line of code you need to use:
$order->XXX = strtoupper($order->XXX);
where XXX is the column name of your custom order field and strtoupper is the name of the toUpperCase function in PHP (which you could easily find out if you search a bit online).

Now, you could also do it with a view override to strreplace the oninput attribute in the input field. However, it will require more complex coding than making the plugin as described above.

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

Time to create page: 0.050 seconds
Powered by Kunena Forum