Query of Code in Address (address/form.php)

  • Posts: 109
  • Thank you received: 5
9 years 9 months ago #189110

-- HikaShop version -- : 2.3.4
-- Joomla version -- : 3.3.6

Hello, there.

Good afternoon!

I have the following query about the hikashopCheckChangeForm code when the "OK" button is clicked in the address/form.php code.

echo $this->cart->displayButton(JText::_('OK'),'ok',$this->params,hikashop_completeLink('address&task=save'),'if(hikashopCheckChangeForm(\'address\',\'hikashop_address_form\')) document.forms[\'hikashop_address_form\'].submit(); return false;');

This code doesn't seem to be executed when the "OK" button is clicked.

What is the purpose of this code? When is it run?

Thanks.

Take care!

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 9 months ago #189147

Hi,

I don't see why it wouldn't be executed. That code is run when you click on the button in order to check that the required data has been entered by the customer before validating the form submission.
Are you sure that you're looking at the correct view file for the correct page on your website ?
The address/form.php might not be used on the checkout based on how you configured your checkout. Instead, it could be the address/show.php which could be used.

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

  • Posts: 109
  • Thank you received: 5
9 years 9 months ago #189539

Thanks, Nicolas.

Yes, you are right. It does get executed. Apologies for the wild goose chase.

I have another question regarding the function (or rather the hikashopCheckField function).

Instead of a popup message appearing when a validation error is found, I like the error message to be displayed inline (for instance, have the label of the input box replaced). As an example, say the post code box does not have a value and the "OK" button is clicked, the label for the post code box will now say "Please enter a value for the field Postcode".

I have modified the following code in hikashopCheckField from

alert(hikashopFieldsJs['validFieldsComp'][type][i]);

to
var labelName = 'label_' + elementToCheck.id;
window.Oby.updateElem(labelName, hikashopFieldsJs['validFieldsComp'][type][i]);

Note that I have added the id for the label in the function getFieldName (in /administrator/components/com_hikashop/classes/field.php) as follows.
return '<label id="label_' .$field->field_namekey. '" for="'.$this->prefix.$field->field_namekey.$this->suffix.'">'.$this->trans($field->field_realname).$required.'</label>';

Unfortunately, the new label is not displayed. I think what I am missing is a call to the document.ready function.

Please could you direct me on how I can get the code to work to show the new label? Do I need to all the window.Oby.ready function? If so, what is the parameter to pass in?

Thanks.

Take care!

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 9 months ago #189565

Hi,

You don't need to use Oby.ready and it wouldn't help.
The code you gave sounds correct for what you want to do.
Are you sure that labelName matches with the id of the label in the HTML ?

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

  • Posts: 109
  • Thank you received: 5
9 years 9 months ago #190027

Thanks, Nicolas.

Yes, the labels match.

I have since discovered code samples used in Hikashop on how to call the function and it (appears to) work.

Thanks.

Take care!

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

Time to create page: 0.058 seconds
Powered by Kunena Forum