Required fields when vendor adds product

  • Posts: 377
  • Thank you received: 7
8 years 6 months ago #239537

-- HikaShop version -- : 2.6.3
-- HikaMarket version -- : 1.7.0
-- Joomla version -- : 3.5.1
-- PHP version -- : 5.5

Hi,

I have a page on website that lets vendor list their products. I've added some custom fields on this page and made them required. Now when I submit a product without filling these custom fields I get validation error. But when all the custom fields are filled and I try to add the product with out title it lists the product without any validation.

How can I make Product title and product price field mandatory. I also tried it after removing all view customizations and custom fields.

Regards

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
8 years 6 months ago #239558

Hi,

For the product name ; it is something that I will add into HikaMarket because the vendor should not provide an empty value for the product name (if he has the right to edit the product name).

About the price it is something more complicated because some store can authorize products without prices.
So I'll more recommend the usage of a custom plugin and the triggers "onBeforeProductCreate / onBeforeProductUpdate".

public function onBeforeProductCreate(&$product, &$do) {
	$this->onBeforeProductUpdate($product, $do);
}
public function onBeforeProductUpdate(&$product, &$do) {
	$app = JFactory::getApplication();
	if($app->isAdmin())
		return;
	$option = JRequest::getCmd('option', '');
	if($option != 'com_hikamarket' || !defined('HIKAMARKET_COMPONENT'))
		return;

	// Check for empty product name
	if(isset($product->product_name) && empty($product->product_name)) {
		$app->enqueueMessage(JText::sprintf('HIKAM_FIELD_REQUIRED', JText::_('PRODUCT_NAME')), 'error');
		$do = false;
		return;
	}
}

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.

Moderators: Obsidev
Time to create page: 0.055 seconds
Powered by Kunena Forum