Easy-profile hikashop orders tab plugin

  • Posts: 1119
  • Thank you received: 114
7 years 11 months ago #257444

-- HikaShop version -- : 2.6.4

Hi,

1.As we use easy-profile i have created some small plugin which adds extra tab and shows user orders. Something similar to hikashop cb plugin. All works well but i see small issue.

When you press on order, it goes to page which url is like this: /component/hikashop/order/show/cid-384/cancel_url-L2RlbW9hZG1pbi9jb21wb25lbnQvY29tcHJvZmlsZXIv

As there is no menu item order details shows on home page between content modules. I do have menu created HikaShop » Customer orders
How can this line be changed:

<?php echo hikashop_completeLink('order&task=show&cid='.$row->order_id.'&cancel_url='.urlencode(base64_encode(JRoute::_('index.php?option=com_comprofiler')))); ?>

So it would go to hikashop orders menu item?

Should be something like this as you would go from menu item to order details: my-orders/order/show/cid-384

2. I have attached plugin and happy to share it with community. However it does have this bug as said above... I am not a developer so would be good if someone could take a look into code and fix it if need it...Only few lines of code...

3. I also would like to create another plugin which would allow to modify user address via easy-profile. Is there any plugin or something i could look?

Kind regards

Attachments:
Last edit: 7 years 11 months ago by kyratn.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 11 months ago #257453

Hi,

1. It's quite easy to do. You need to use that code instead:

<?php echo hikashop_completeLink('order&task=show&cid='.$row->order_id.'&Itemid=XXX&cancel_url='.urlencode(base64_encode(JRoute::_('index.php?option=com_comprofiler')))); ?>
where XXX is the id of the menu item with the alias "my-orders". So like the search plugins or the modules of HikaShop, the solution is to have a "menu" setting in your plugin so that you can configure the id of your menu item to set it in that URL.

2. We'll be happy to add it to the integration documentation once you provide a finished version.

3. This would have to be much complex. First, we don't have such integration with anything else like that.
And the address edit form isn't meant to be embedded somewhere else.
Why not instead just add a link to your easy profile page which would redirect the customer to the addresses manager of HikaShop's control panel ?

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

  • Posts: 1119
  • Thank you received: 114
7 years 11 months ago #257462

Hi,

1. It was easier then i thought. Added possibility to enter menu item id and all fine now.

Could you please tell me what does cancel_url after item ID? Can this line be removed?

&cancel_url='.urlencode(base64_encode(JRoute::_('index.php?option=com_comprofiler'))));

2. I have attached final version of the plugin. It works well on my end. If you could check it for any mistakes it would be good.

3. What i am looking to have is that user could see/change hes all details via easy-profile tabs. That's why asking for. Probably some kinda link will be easiest solution here.

Thanks Nicolas for your help.

Have a great evening

File Attachment:

File Name: tab_hikash...2-11.zip
File Size:2 KB

Attachments:
Last edit: 7 years 11 months ago by kyratn.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 11 months ago #257482

Hi,

1. The cancel_url parameter allows HikaShop to know the URL to return to when the customer click on the "back" button on order details page. So instead of removing it, you should put the URL used to access the profile page where the orders listing is displayed.

2. Thanks. See point 1 :)

3. Yes, a link will be way way simpler. Integrating the address edition interface in a tab there would be quite a lot of work I expect.

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

  • Posts: 1119
  • Thank you received: 114
7 years 11 months ago #257543

Hi,

1. Indeed back button wasn't working. It was giving 404 error. Fixed and attached new file. I hope this is a last one :)

2. I think I have found very easy solution to display address edition page. Installed plugin called include component. Created new tab and added tag which now shows address edition page. However there is a small issue. When you edit address and press button save it redirects to homepage with url: /component/hikashop/address
I think this can be changed via one of the address view files. Could you please help me with it?

File Attachment:

File Name: tab_hikash...2-12.zip
File Size:2 KB


Thank you

Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 11 months ago #257579

Hi,

1. Great ! I've published it on GitHub here:
github.com/HikaShop/jsn-tab-hikashop-orders

2. Hard to say. Could you provide more information on how to added the address edition in a tab ? Could you provide some screenshots of the settings to do that and the result and the problem ?

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

  • Posts: 1119
  • Thank you received: 114
7 years 11 months ago #257603

Hi,

1. Awesome. Thanks

2. To have address addition tab I did this. I have installed such plugin: extensions.joomla.org/extension/include-component
In easy-profile I have created new group and named it address test0, then I have created user field named address test, type html delimeter and assigned it to that group. Added such tag inside that user field {component url='index.php?option=com_hikashop&view=address&layout=listing' }

Now it shows address edition page inside tab. All should work I think but then you press edit address, pop-up is displayed and then save it redirects to home page and shows address edition between all modules. Same as there would be no menu item for it...And url is like this: /component/hikashop/address
Maybe there is a way to change where it redirects after you press save button...

I also have attached some screenshots.

Thank you

Attachments:
Last edit: 7 years 11 months ago by kyratn.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 11 months ago #257612

Hi,

You would have to change the line:

echo '<html><head><script type="text/javascript">window.parent.location.href=\''.$url.'\';</script></head><body></body></html>';
to:
echo '<html><head><script type="text/javascript">window.parent.location.href=\'XXX\';</script></head><body></body></html>';
where XXX is the URL of the profile in the file components/com_hikashop/controllers/address.php

The following user(s) said Thank You: kyratn

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

  • Posts: 1119
  • Thank you received: 114
7 years 11 months ago #257709

It works. Thank you for your help!

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

  • Posts: 13
  • Thank you received: 1
7 years 5 months ago #272144

Thanks for a great plugin

This was just what I was looking for - however I see one bug

If you look at a proifile as an admin it pulls back the admins orders not the profile you are looking at. Is that an easy fix?

I think its around the

$filters = array('a.order_user_id='.hikashop_loadUser());

I'm guessing we must make a more complex query linking the easyprofile ID to the CMS ID to the hikashop userID and back to the order table

I'm not sure how to complete this but if someone gave me a pointer I would happily work on it.

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

  • Posts: 1119
  • Thank you received: 114
7 years 5 months ago #272145

Hi,

This line of code is from CB plugin. That plugin should have such issue too.
I am not sure how can this be fixed so lets wait for Nicolas answer. He should be able to help.


Kind Regards

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

  • Posts: 13
  • Thank you received: 1
7 years 5 months ago #272168

OK Im getting somewhere with this but I think the way Hikashop_loaduser() works with the view is holding me back - suggestions welcome

To recap I have 2 User Stories

US1: " As a club Admin in the front end I want to be able to look at a list of members and when I click on one member be able to see the hikashop orders for that member"
US2: " As a club admin in the front end I want to be able to look at a list of hikashop orders for a member and when I click on one order be able to see the order details"

I have fixed US1 using kyratn plugin with one change to the filter statement
Instead of using

$filters = array('a.order_user_id='..hikashop_loadUser());

on line 34 to set the hikashop ID I use

$userClass = hikashop_get('class.user');
$hikashop_id = $userClass->getID($id);
$filters = array('a.order_user_id='.$hikashop_id);

US2 remains a problem as the link to the detail for an order seems to fail - I think the Hikashop view is failing as its not expecting an order that doesn't belong to the logged in user.

Attachments:

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

  • Posts: 13
  • Thank you received: 1
7 years 5 months ago #272187

Success - sort of - I've found the problem

show() calls _order('order') which calls loadfullorder($order_id,TRUE)

the TRUE on loadfullorder checks to make sure the current user is the owner of the order.

I think the answer will be to set up a new type of view

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 5 months ago #272185

Hi,

Indeed. On the frontend, only the owner of an order has the right to access the details of an order.
This is handled by the function loadFullOrderin the file administrator/components/com_hikashop/classes/order.php

} elseif($checkUser) {
			if(empty($order->customer->user_cms_id) || (int)$order->customer->user_cms_id == 0){
				// guest checkout
				$token = JRequest::getVar('order_token');
				if(empty($order->order_token) || $token != $order->order_token){
					//invalid token in the URL
					return null;
				}
			}elseif( hikashop_loadUser() != $order->order_user_id ){
				//on front end and user is different from user in order
				return null;
			}
		}
So you would have to rewrite that piece of the function to not return null when the currently logged in user is a club admin.

Last edit: 7 years 5 months ago by nicolas.

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

  • Posts: 29
  • Thank you received: 0
4 years 2 months ago #323800

Did you ever have any success getting this to work? I need a way for an admin to see customer orders in front-end?

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

Time to create page: 0.107 seconds
Powered by Kunena Forum