Attaching files to order

  • Posts: 134
  • Thank you received: 6
9 years 8 months ago #224361

-- HikaShop version -- : 2.6.0

Hi,

I would like to manually attach some downloadable from the user files, for each order (like infoice, warranty card and others). The files should be unique for each order, so they cannot be pre-added.

I searched but could not find any ideas how to do that, so I will apreciate your help.

Thank You!
Iliya

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

  • Posts: 134
  • Thank you received: 6
9 years 8 months ago #224367

Ok, I think I find that out.

I made another file type custom field for the order table and made it visible for the Front-end.
So when adding file to that field it is shown at the bottom of the order in front-end.

But what happens when the order has been made without registration?

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

  • Posts: 13201
  • Thank you received: 2322
9 years 8 months ago #224374

Hi,

If the order has been made without registration so the customer will not have access to the orders in frontend.
But in the email, the name of the file will be displayed, so you can potentially edit the email, set the file full path and send it to the customer, that way he can have all the informations even if he's not registered.

The emails can be sent from the order edition page in backend.

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

  • Posts: 134
  • Thank you received: 6
9 years 8 months ago #224452

Thank You Xavier.

Just could you please help me fixing the full file path. Where are those files saved and how should the link look like?

EDIT: I found the files in "/media/com_hikashop/upload/safe/", but that folder is not public accessible I think?

Regards,
Iliya

Last edit: 9 years 8 months ago by filiar.

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

  • Posts: 13201
  • Thank you received: 2322
9 years 8 months ago #224457

Hi,

The location of the files depends on your settings under Configuration > Main > Files.
The link should look like this:

http://yourwebsite.ext/the_path_set_in_the_settings
If you are using this method, check your permission settings via ftp in order to lock the access to the folder but enable the access to the file.

And yes, the files in the safe folder are not directly accessible.

Last edit: 9 years 8 months ago by nicolas.

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

  • Posts: 134
  • Thank you received: 6
9 years 8 months ago #224555

Thank You, Xavier.

So I solved it that way:

  1. As you requested I made files readable (by changing .htaccess file permissions for safe folder to "allow from all") and the folder properties itself to 751 (denied read access, but allowed execute for word)
  2. Changed those lines in media/com_hikashop/mail/order_status_notification.preload.php
    	if(hikashop_level(2)) {
    		$fields = $fieldsClass->getFields('frontcomp',$data,'order','');
    		foreach($fields as $fieldName => $oneExtraField) {
    			if(isset($data->$fieldName) && !isset($data->cart->$fieldName))
    				$data->cart->$fieldName = $data->$fieldName;
    			if(empty($data->cart->$fieldName))
    				continue;
    			echo $sep . $fieldsClass->trans($oneExtraField->field_realname).' : '.$fieldsClass->show($oneExtraField, $data->cart->$fieldName,'user_email');
    			$sep = '<br />';
    		}
    	}
    to
    	if(hikashop_level(2)) {
    		$fields = $fieldsClass->getFields('frontcomp',$data,'order','');
    		foreach($fields as $fieldName => $oneExtraField) {
    			if(isset($data->$fieldName) && !isset($data->cart->$fieldName))
    				$data->cart->$fieldName = $data->$fieldName;
    			if(empty($data->cart->$fieldName))
    				continue;
    			$val = ($oneExtraField->field_namekey=='order_invoice' || $oneExtraField->field_namekey=='order_warranty')
    				? '<a href="'.HIKASHOP_LIVE.'media/com_hikashop/upoad/safe/'.$data->cart->$fieldName.'">'.$data->cart->$fieldName.'</a>'
    				: $fieldsClass->show($oneExtraField, $data->cart->$fieldName,'user_email');
    			echo $sep . $fieldsClass->trans($oneExtraField->field_realname).' : '.$val;
    			$sep = '<br />';
    		}
    	}


This way for the custom file fields (that I created named 'order_invoice' and 'order_warranty') links to the files will be added in the notification email.

So the question now is what will happen with that code after I update HS. I suppose changes will be overwritten.

How to solve that? And do you think about implementing such links to files?

Last edit: 9 years 8 months ago by filiar.

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

  • Posts: 13201
  • Thank you received: 2322
9 years 8 months ago #224560

Hi,

To keep the modifications even when updating, you have to create override so edit the emails via the menu System > Emails (in HikaShop) instead of editing the files in the folder directly. That way, you will always keep your modifications.

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

Time to create page: 0.155 seconds
Powered by Kunena Forum