How to limit max order quantity to 1 for backend?

  • Posts: 64
  • Thank you received: 0
11 years 2 months ago #123752

-- HikaShop version -- : 2.2.1
-- Joomla version -- : 3.0.4 Stable
-- PHP version -- : 5.4.7

I have the same scenario for backend as I have here www.hikashop.com/forum/2-general-talk-ab...eforecartupdate.html for front end.

If I use onAfterProductQuantityCheck ,it does not fire for backend.Also onBeforeOrderProductsUpdate did not work for me.
The code is-

function onBeforeOrderProductsUpdate(&$order, &$do){
		$maxQtyMsg 	= 'Max quantity for product is 1.';
		$canOrder     = $this->canOrder($order->product[0]->product_id,$order->product[0]->order_product_quantity);
		if(!$canOrder){
			$do = false;
			JFactory::getApplication()->enqueueMessage($maxQtyMsg, 'error');
		}	
	}
The problem is, even if we set $do=false it updates order product.

I do not want to add/update product if quantity is more than one.

Regards,

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

  • Posts: 26159
  • Thank you received: 4028
  • MODERATOR
11 years 2 months ago #123818

Hi,

	$do = true;
	$dispatcher->trigger('onBeforeOrderProductsUpdate', array(&$order, &$do) );
	if(!$do)
		return false;
I am sure that if you set "$do = false" the process will stopped.
But please check the trigger "onBeforeOrderUpdate" too, the order product one is called on specific cases that the backend can may not use because it's a more "raw" usage.

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: 64
  • Thank you received: 0
11 years 2 months ago #123874

Thanks,but solution does not work for me.

I found that problem is something else.

The problem is $do value only affects total order price not the order product.For example if for Product A $do value is false ,system adds Product A to order but not it's price to total price.

Could you please help me how to solve it?

Please let me know if not clear.

Regards,

Last edit: 11 years 2 months ago by irfanhanfi.

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

  • Posts: 26159
  • Thank you received: 4028
  • MODERATOR
11 years 2 months ago #124013

Hi,

The problem is $do value only affects total order price not the order product.For example if for Product A $do value is false ,system adds Product A to order but not it's price to total price.

Sorry but no. If in the trigger you set the variable "$do" to false, it will stop the all process.
It's exactly what is written in my previous message. The "return false" stop the process and get out of the function.

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.

Time to create page: 0.067 seconds
Powered by Kunena Forum