Subvendor item deletion & Main order update

  • Posts: 171
  • Thank you received: 9
10 years 1 month ago #173645

-- HikaShop version -- : 2.3.3.
-- HikaMarket version -- : 1.4.4
-- Joomla version -- : 3.3.4.

Hi Jerome,

We're in really final stage after long months of work and "playing" with the code.
2 small problems we noticed, both related in updating the main order (sale).

1.) In default a subvendor is not permitted to delete items from the order. After modifing the template (show_products.php) delete button is shown, and after a page refresh the item is deleted.But the item is just deleted from the sub-sale, in sale it's still shown. I know that deleting is a main vendor's only right, but we should need it to work for sub-vendor as well.

2.) We have 2 fields for each ordered item which are empty in default by custom reasons. But the user who made the order should fill these fields later. We have solved it by editing show function in /components/com_hikashop/views/view.html.php but the problem is the same as in 1.), the main order is not updated, just the subsale.

function show(){
	$type = 'order';
	$order =& $this->_order($type);
	$config =& hikashop_config();
	$download_time_limit = $config->get('download_time_limit',0);
	$this->assignRef('download_time_limit',$download_time_limit);
	$download_number_limit = $config->get('download_number_limit',0);
	$this->assignRef('download_number_limit',$download_number_limit);
	$order_status_download_ok=false;
	$order_status_for_download = $config->get('order_status_for_download','confirmed,shipped');
	if(in_array($order->order_status,explode(',',$order_status_for_download))){
		$order_status_download_ok=true;
	}
	$this->assignRef('order_status_download_ok',$order_status_download_ok);
	$popup = hikashop_get('helper.popup');
	$this->assignRef('popup',$popup);
	hikashop_setPageTitle(JText::_('HIKASHOP_ORDER').': '.$this->element->order_number);	
	if(isset($_POST['update_teteldatum'])){
		$app = JFactory::getApplication();
		$db = JFactory::getDBO();		
		$order_id = JRequest::getVar('order_id');
		$product_id = JRequest::getVar('product_id');
		$redirect_url = JRequest::getVar('redirect_url');
		$data = JRequest::getVar('data', array(), '', 'array');
		if(!JSession::checkToken()) {
			$app->enqueueMessage(JText::_('INVALID_TOKEN'), 'error');
		} else {
			if( (!isset($data['item']['kiszallitva_tetel'])) || ($data['item']['kiszallitva_tetel']==='00000000000') || (!isset($data['item']['szallitolevel_szama'])) || (empty($data['item']['szallitolevel_szama'])) ) {
				$app->enqueueMessage(JText::_('A dátum és/vagy a szállítólevél száma mező üres!'), 'error');
			}else {
				$query = 'UPDATE '.hikashop_table('order_product').' SET kiszallitva_tetel='.$db->Quote($data['item']['kiszallitva_tetel']).', szallitolevel_szama='.$db->Quote($data['item']['szallitolevel_szama']).' WHERE order_product_id='.$db->Quote($product_id);	
				$db->setQuery($query);
				$result = $db->query();
				//$mainframe->$redirect_url;
				JError::raiseNotice( 100, 'A kiszállítás dátuma és a szállítólevél száma elmentve!' );
				JFactory::getApplication()->redirect($redirect_url);
				//return;
			}
		}
	}
}

Thanks for your help and patience in advance.
Regards,
PePe

Last edit: 10 years 1 month ago by Jerome. Reason: indent code

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 1 month ago #173707

Hi,

Sorry for the delay.
I had to analyze your problem and check the HikaMarket/HikaShop code.

The feature you asked must be provided by the HikaMarket order class (administrator/components/com_hikamarket/classes/order.php) and I won't be able to help you for that before several weeks.
I already re-factored the order class in order to add new big features, this file is today pretty big (more than 2500 lines) and the algorithm are quite complex.
If I want to add your feature, it will break an important part of the file and I should rewrite 4 big the functions.
I am currently working on the characteristic/variant system and I not able to work on these two big development in the same time ; the order class is too complex specially if we want to change the core algorithm.
Because the fact that it is not possible to edit a sub-sale for the products is written in the algorithm, it's something in the specification so it's something which will impact more than you can imagine in HikaMarket if we want to change that.

So for the moment, my only answer is that I am not able to implement this feature request.
Because it's a feature request and the only thing I can do right now, is to create a new task in my TODO list.

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: 171
  • Thank you received: 9
10 years 1 month ago #173722

Jerome, I understood, not happy, but no problem. Both you and Nicolas helped me a lot earlier, so I can not be enough thankful.

Just one thing which maybe can help me and maybe already in the code, just I do not know who to call it.
When system loads the order_id, is there a way to load that order_id's parent (main order's) order_id?

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 1 month ago #173734

Hi,

The best will be to add some code in your system in order to perform the action in the main-sale and not in the sub-sale.
Keeping a "link" between the sale and the sub-sale is already present, but the inverse is not.
So instead of removing the product in the sub-sale, the best is to find the product in the main-sale and remove it. So HikaMarket will remove the product in the two elements and process the prices correctly.

I hope my explanation is clear enough.

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: 171
  • Thank you received: 9
10 years 1 month ago #173739

Jerome wrote: Hi,

The best will be to add some code in your system in order to perform the action in the main-sale and not in the sub-sale.
Keeping a "link" between the sale and the sub-sale is already present, but the inverse is not.
So instead of removing the product in the sub-sale, the best is to find the product in the main-sale and remove it. So HikaMarket will remove the product in the two elements and process the prices correctly.

I hope my explanation is clear enough.

Regards,


Yes, that's what I had think in my mind, when I asked for a trick to find sale's ID instead sub-sale's ID.

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 1 month ago #173742

Hi,

When you got the sub-sale, you have the id of the main sale in the value "$order->order_parent_id"
Same thing for the order product, you have the value "$order_product->order_product_parent_id" which point to the order_product in the main sale.

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.
The following user(s) said Thank You: pepecortez

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 1 month ago #173842

Hi,

I was thinking about your request and I got an idea.
HikaMarket is using the HikaShop triggers to work and it call the triggers as well.

So you can use the trigger "onAfterOrderUpdate" in order to know when an HikaMarket order has been modified.
Thanks to the JApplication, you can check that you're right in the front-end and you can also check that the user is currently calling an HikaMarket controller (to be sure that the updated order is not due to something in HikaShop).

Then, you can read the content of "data[order][product]" in the post and apply the modification that HikaMarket does on the subsale, to his parent sale.

Your request is just on item deletion and my problem is that, if I had to manage the product deletion I have to manage the rest (product modification, additional modification, customer modification, address modification, etc) which will have a lot of impact and would require a lot of code to manage all possible cases.
But in your case, if you just want the product deletion, I think the use-case are quite few so you could use a plugin and the trigger to match that case and do the modification job on the main order.

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.
The following user(s) said Thank You: pepecortez

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

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