Replace product required item javascript alert

  • Posts: 128
  • Thank you received: 3
10 years 1 week ago #213786

-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.1
-- PHP version -- : 5.3.24

I have a product that has a check box item that I require to be checked before the product can be added to cart (see the product here ). I have a custom error message for when it's not checked. Right now the page just does a simple javascript alert with the error message. Is there a way that I can change this function from a javascript alert to where it will show a hidden div on the page that contains the custom error message without doing a core override? I've tried finding the alert function in the Display->Views, but I can't seem to find it. Is this written in a helper file or something?

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

  • Posts: 26274
  • Thank you received: 4045
  • MODERATOR
10 years 1 week ago #213806

Hi,

The "alert" is made by the function "hikashopCheckField" in the hikashop.js file.
If you re-define that function after the inclusion of "hikashop.js", you will override it and it will allow you to use something else than an "alert".

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 128
  • Thank you received: 3
9 years 6 months ago #233233

Is this the same function that does alerts in the checkout for if you do not select a shipping method or do not select a payment method?

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

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 6 months ago #233247

Hi,

No. This function is for the custom fields check. For the shipping/payment methods selection, it's another function.

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

  • Posts: 128
  • Thank you received: 3
9 years 6 months ago #233358

Hello,
I see that this alert is controlled by hikashopCheckMethods function, but I don't see this function in any of the checkout views. Is it in one or is it written in another way? I would like to have the alerts come in as an error into the inner html of the system message container. Is this possible without having to edit core files?

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

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 6 months ago #233364

Hi,

You must have missed it. It's called in the file "step" of the view "checkout" on the line:

echo $this->cart->displayButton($checkout_next_button,'next',$this->params, hikashop_completeLink('checkout&task=step&step='.$this->step+1),'if(hikashopCheckChangeForm(\'order\',\'hikashop_checkout_form\')){ if(hikashopCheckMethods()){ document.getElementById(\'hikashop_validate\').value=1; this.disabled = true; document.forms[\'hikashop_checkout_form\'].submit();}} return false;','id="hikashop_checkout_next_button"');
it is defined in the file components/com_hikashop/views/checkout/view.html.php in the function "step".
You would have to redefine that function (copy/paste it) in the "step" file of the "checkout" view so that you could override it in the view and don't loose your changes when updating.

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

Time to create page: 0.062 seconds
Powered by Kunena Forum