Required Custom fields on checkout can be blank

  • Posts: 177
  • Thank you received: 5
7 years 7 months ago #267094

-- url of the page with the problem -- : demo.hikashop.com
-- HikaShop version -- : 3.0.1
-- Joomla version -- : 3.6.5

Create Custom field in table Order and mark it as required.



On checkout page i see this field with asterisk, but can don't fill it and order will be created. What I did wrong? How do not allow create order until fill this field?



In 2.6.3 checkout.html in source code I see:
<!--
window.hikashopFieldsJs['reqFieldsComp']['order'] = ['delivery_adress','phone'];
window.hikashopFieldsJs['validFieldsComp']['order'] = ['Пожалуйста укажите ваш адрес.','Укажите номер телефона'];
//-->
which popup error message that fields are not filled.

But I don't see it in 3.0.1 source.

Attachments:
Last edit: 7 years 7 months ago by alikon1.

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

  • Posts: 177
  • Thank you received: 5
7 years 7 months ago #267095


This field is blank in admin panel.

Attachments:

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 7 months ago #267110

Hello,

I know that Nicolas submit a patch recently (last week) in order to fix an issue with the order custom fields and new checkout system.
Please re-download HikaShop 3.0.1 in order to be sure that it fix your problem too.

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: 177
  • Thank you received: 5
7 years 7 months ago #267139

We have already made many edits to the files for our features after installed 3.0.1, downloaded in April 5th. Maybe possible replace only the desired file without updating everything?

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

  • Posts: 177
  • Thank you received: 5
7 years 7 months ago #267140

Unfortunately, you have unclear versions of the updates. Every time in the admin panel I see that the latest version is installed. But each time you have to reinstall the same 3.0.1. We checked everything on the test server, installed it on the production server and started to receive orders with empty fields, when people accidentally press Finish. You would like regularlabs.com wrote a page with all the updates and revision versions and what bugs are fixed. :(

The following user(s) said Thank You: pixeldiele

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
7 years 7 months ago #267145

Hi,

That's what we do here:
www.hikashop.com/support/documentation/5...ashop-changelog.html
However, we only do that for releases. Not for nightly builds, because we publish nightly builds almost every day. If we were to publish a new version of HikaShop every day, it would bother everyone having to update their HikaShop all the time for nothing.


This issue with the required check not being done properly only occurs when you don't set any product or category restriction in the custom field. So you can always select your main category in the category restriction of the custom field and it will work properly.
Otherwise the patch is to replace the code:

if($field->field_table == 'order' && ($field->field_products != 'all' || $field->field_categories != 'all')){
			$cartClass = hikashop_get('class.cart');

			$cart = $cartClass->loadFullCart(true);
			$inCart = false;

			$restricted_products = array ();
			$restricted_categories = array();
			//Product check
			if($field->field_products != 'all'){
				$restricted_products = explode(',', $field->field_products);
				$restricted_products = array_filter($restricted_products);

				if (!isset($cart->cart_products) && isset($cart->products)) {
					$cart->cart_products = $cart->products;
				}

				foreach($cart->cart_products as $cart_product){
					if(in_array($cart_product->product_id, $restricted_products))
						$inCart = true;
				}
			}
			//Category check
			if($field->field_categories != 'all' && !$inCart){
				$restricted_categories = explode(',', $field->field_categories);
				$restricted_categories = array_filter($restricted_categories);

				$fieldClass = hikashop_get('class.field');
				$cart_categories = $fieldClass->getCategories('order', $cart);

				foreach($restricted_categories as $restricted_category){
					if($field->field_with_sub_categories && in_array($restricted_category, $cart_categories['parents']))
						$inCart = true;
					else if(!$field->field_with_sub_categories && in_array($restricted_category, $cart_categories['originals']))
						$inCart = true;
				}
			}
by:
if($field->field_table == 'order' && (!in_array($field->field_products, array('all', '')) || !in_array($field->field_categories, array('all', '')))){
			$cartClass = hikashop_get('class.cart');

			$cart = $cartClass->loadFullCart(true);
			$inCart = false;

			$restricted_products = array ();
			$restricted_categories = array();
			//Product check
			if(!in_array($field->field_products, array('all', ''))){
				$restricted_products = explode(',', $field->field_products);
				$restricted_products = array_filter($restricted_products);

				if (!isset($cart->cart_products) && isset($cart->products)) {
					$cart->cart_products = $cart->products;
				}

				foreach($cart->cart_products as $cart_product){
					if(in_array($cart_product->product_id, $restricted_products))
						$inCart = true;
				}
			}
			//Category check
			if(!in_array($field->field_categories, array('all', '')) && !$inCart){
				$restricted_categories = explode(',', $field->field_categories);
				$restricted_categories = array_filter($restricted_categories);

				$fieldClass = hikashop_get('class.field');
				$cart_categories = $fieldClass->getCategories('order', $cart);

				foreach($restricted_categories as $restricted_category){
					if($field->field_with_sub_categories && in_array($restricted_category, $cart_categories['parents']))
						$inCart = true;
					else if(!$field->field_with_sub_categories && in_array($restricted_category, $cart_categories['originals']))
						$inCart = true;
				}
			}
in the file administrator/components/com_hikashop/classes/field.php

The following user(s) said Thank You: alikon1, pixeldiele

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

  • Posts: 177
  • Thank you received: 5
7 years 7 months ago #267203

Thank you. It's Ok now.

nicolas wrote: This issue with the required check not being done properly only occurs when you don't set any product or category restriction in the custom field. So you can always select your main category in the category restriction of the custom field and it will work properly.


I have some problems with that restriction begining from Hikashop maybe 2.5-2.6.x versions, don't remember exactly and still in 3.0.1
When open custom field, restriction Categories is filled with strange blank square. And if I save custom field with that square, it will disappear from everywhere. So every time I open custom field, I shoud remove this square before save :silly:

Attachments:
Last edit: 7 years 7 months ago by alikon1.

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

  • Posts: 177
  • Thank you received: 5
7 years 7 months ago #267205

Also I have Radiobutton custom field in checkout Yes/No. And despite No selected as default value, there is no default value checked on page.
Before update it was checked when checkout page loaded.

Attachments:

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

  • Posts: 177
  • Thank you received: 5
7 years 7 months ago #267207

Try it on your demo.
Create Order table Custom field with radio type and defaiult No.



But in checkout nothing selected.


This is not critical for us. Empty field = No field. If the buyer select Yes, we see it correctly.
But before it worked.

Attachments:
Last edit: 7 years 7 months ago by alikon1.

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
7 years 7 months ago #267266

Hi,

Thanks. We've added a patch on our end for that.

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

Time to create page: 0.104 seconds
Powered by Kunena Forum