Skip to main content

How to limit max order quantity to 1 for backend?

More
13 years 2 weeks ago #123752 by irfanhanfi
-- 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-
Code:
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.

More
13 years 2 weeks ago #123818 by Jerome
Hi,
Code:
$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.

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

More
13 years 2 weeks ago - 13 years 2 weeks ago #123874 by irfanhanfi
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: 13 years 2 weeks ago by irfanhanfi.

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

More
13 years 2 weeks ago #124013 by Jerome
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.

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

Time to create page: 0.174 seconds
Powered by Kunena Forum