Redundant Call to CheckChangeForm

  • Posts: 109
  • Thank you received: 5
10 years 1 month ago #199257

-- HikaShop version -- : 2.3.4
-- Joomla version -- : 3.6.3
-- PHP version -- : 5.5.17

Hello, there.

Good morning!

Please could you explain the purpose of the following code in checkout/step.php?

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"');

In media/com_hikashop/js/hikashop.js, the hikashopCheckChangeForm does not have any test for the value of 'order' in the type parameter. Does this mean that the call to hikashopCheckChangeForm from checkout/step.php is redundant?

Thanks.

Take care!

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

  • Posts: 26235
  • Thank you received: 4036
  • MODERATOR
10 years 1 month ago #199315

Hi,

The code will check the checkout form (to check the order) and submit it if good.
I don't understand why you think that the code is redundant.

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: 109
  • Thank you received: 5
10 years 2 weeks ago #200628

Thanks, Jerome.

As stated, there is no test for the value of "order" in the hikashopCheckChangeForm function in the file media/com_hikashop/js/hikashop.js. How does the hikashopCheckChangeForm function check if the order is valid?

Thanks.

Take care!

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

  • Posts: 83831
  • Thank you received: 13572
  • MODERATOR
10 years 2 weeks ago #200638

Hi,

There are tests for the value "order" in hikashopCheckChangeForm so I don't see what you're talking about.
This is the code of that function which test the custom fields on the checkout:

for(var i = hikashopFieldsJs['reqFieldsComp'][type].length - 1; i >= 0; i--) {
		elementName = 'data['+type+']['+hikashopFieldsJs['reqFieldsComp'][type][i]+']';
		if(typeof(varform.elements[elementName]) == 'undefined')
			elementName = type+'_'+hikashopFieldsJs['reqFieldsComp'][type][i];

		elementToCheck = varform.elements[elementName];
		elementId = 'hikashop_'+type+'_'+ hikashopFieldsJs['reqFieldsComp'][type][i];
		el = d.getElementById(elementId);

		if(elementToCheck && (typeof el == 'undefined' || el == null || typeof el.style == 'undefined' || el.style.display!='none') && !hikashopCheckField(elementToCheck,type,i,elementName,varform.elements)) {
			if(typeof(hikashopFieldsJs['entry_id']) == 'undefined')
				return false;

			for(var j = 1; j <= hikashop['entry_id']; j++) {
				elementName = 'data['+type+'][entry_'+j+']['+hikashopFieldsJs['reqFieldsComp'][type][i]+']';
				elementToCheck = varform.elements[elementName];
				elementId = 'hikashop_'+type+'_'+ hikashopFieldsJs['reqFieldsComp'][type][i] + '_' + j;
				el = d.getElementById(elementId);
				if(elementToCheck && (typeof el == 'undefined' || el == null || typeof el.style == 'undefined' || el.style.display != 'none') && !hikashopCheckField(elementToCheck,type,i,elementName,varform.elements)) {
					return false;
				}
			}
		}
	}
It does the check for the custom user fields, the custom address fields and the custom order fields based on what is given to that function in the first parameter. If you remove that call, it won't check the custom order fields on the checkout and thus you'll be able to finish a step with the "fields" view on the checkout even if you have required custom order fields that are not filled. So it's not redundant, it's the way it should be.

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

Time to create page: 0.035 seconds
Powered by Kunena Forum