Jump to content

Recommended Posts

For globally shipping products the customs need a HS (Harmonised System) code and a Country of Origin.
I still have no idea why this is not a default feature of Prestashop, so i created a module for this.

Screenshot2023-08-01at14_19_19.thumb.png.7b192595e71299474aa78658f1905dd0.png

After installing the module you can find a HS code and a country of origin field in the back office for each product. (as show in the image above)
Afterwards you can easily add the HS code and country of origin on your delivery slips and/or invoices.

Screenshot2023-08-01at14_20_03.png.94284443c0343b6acefeaba854231847.png

 

Installation
You can install this module on any Prestashop 1.7 and Prestashop 8 shop.


After installing the module you would have to manually edit the invoice/delivery slip template.
(because Prestashop does not allow this with the module installation)
In the module there is a folder called 'pdf' if you place this folder in your /themes/YOUR-THEME/ folder you are done.

Github link


Download: hscodes.zip

Updates:
    * 01-08-2023 add country of origin to the module for reach product

Edited by Inform-All
Country of Origin (see edit history)
  • Like 1
  • Thanks 5
Link to comment
Share on other sites

  • 4 weeks later...
2 hours ago, odinp123 said:

I'm going to give this module a try. We were just discussing if we should use "features" feature instead.
To my understanding we also need to supply Country of Origin

Hi
Let me know what you think of this module!
In my customers use case the carrier notes the country of origin, but let me know if you have any other ideas or extensions to this module.

Link to comment
Share on other sites

I've given it a spin on PrestaShop 1.7.5.2

Here I unfortunately experience a problem when saving.

While the HS field data is saved to database, it seems like the save action on product pages hangs (screenshot attached).

 

I've just tested it on 1.7.7.4 here it seems like the same bahaviour

Screenshot 2021-05-07 at 09.53.17.png

Link to comment
Share on other sites

On 5/5/2021 at 1:36 PM, Inform-All said:

Hi
Let me know what you think of this module!
In my customers use case the carrier notes the country of origin, but let me know if you have any other ideas or extensions to this module.

Just to clear up any confusion. The Country of Origin should be applied to each item line on the invoice. It is not where the parcel originates from, but rather where the item originates from. So for instance a pacel originating from Germany, this has to be on the invoice, ie.

T-shirt HS: 1234567890 CO: PT

Skirt HS: 2134567890 CO: PL

and so on.

Edited by odinp123 (see edit history)
Link to comment
Share on other sites

2 hours ago, odinp123 said:

I've given it a spin on PrestaShop 1.7.5.2

Here I unfortunately experience a problem when saving.

While the HS field data is saved to database, it seems like the save action on product pages hangs (screenshot attached).

 

I've just tested it on 1.7.7.4 here it seems like the same bahaviour

Screenshot 2021-05-07 at 09.53.17.png

Could you enable debug mode, and also share what errors your console gives?

Link to comment
Share on other sites

Unfortunately there is no stacktrace from debug mode.

 

Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
    error https://redacted/admin/themes/default/js/bundle/product/form.js?1.7.7.4:700
    https://redacted/admin/themes/new-theme/public/main.bundle.js:277

 

This is all i get in the console
   

Edited by odinp123 (see edit history)
Link to comment
Share on other sites

Could it be that

actionProductUpdate

Should be changed to

 actionProductSave

 

actionProductSave

This hook is called while saving products

Located in: /classes/Product.php

 

actionProductUpdate

This hook is displayed after a product has been updated

Located in:

 

My thought is that, when you save the product, after its saved actionProductUpdate is called, and IT calls save(); aka actionProductSave, that calls actionProductUpdate ... and so on. Creating an infinite loop

Link to comment
Share on other sites

35 minutes ago, odinp123 said:

Could it be that



actionProductUpdate

Should be changed to



 actionProductSave

 

actionProductSave

This hook is called while saving products

Located in: /classes/Product.php

 

actionProductUpdate

This hook is displayed after a product has been updated

Located in:

 

My thought is that, when you save the product, after its saved actionProductUpdate is called, and IT calls save(); aka actionProductSave, that calls actionProductUpdate ... and so on. Creating an infinite loop

Nope.
It looks like a different problem, please send me a private message with some login credentials so i can have a look.

Edited by Inform-All (see edit history)
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

Hello, many thank you for this module, I am using Advanced Invoice Template plugin and I am entering Origin information to Reference field and using this {$order_detail.product_reference}  for Origin of the manufacturer, I was using UPC code field for the HS code and using this attribute {$order_detail.product_upc} for the HS code to show on the invoice.

How can I use HS code field on my invoice? Do you have any idea what the attribute should be for this field?

Link to comment
Share on other sites

  • 3 weeks later...

Hello, 

I am also having the same problem, where the HS code disappears after I save it and therefore I cannot make it appear on my invoices. 
Was there a solution found for this? 

Thank you!
 
 

Link to comment
Share on other sites

To put the HS in the invoice manually you should use the hscode attribute.
Because every product now has the field .hscode, you should first loop over your products inside your invoice template, then you can display the hscode for each product.

This would be the bare minimum, if you are $order_details contains the products.

{foreach $order_details as $order_detail}
    {$order_detail.hscode}
{/foreach}

 

Link to comment
Share on other sites

8 minutes ago, Roar said:

Hello, 

I am also having the same problem, where the HS code disappears after I save it and therefore I cannot make it appear on my invoices. 
Was there a solution found for this? 

Thank you!
 
 

Please enable debug mode, it looks like there is an error in the product data you are tying to save.

Link to comment
Share on other sites

HI, 

Thank you for your quick reply. 
I tried turning on debug but can't seem to see what might be causing it. I am no expert though, so I will ask my webmaster to check in debug too (he has been trying to find a solution for a while now, which is why I sent this message here). I enter the code, save the product, all seems good, then when I leave the product page and return it is back to 0 being the code. 

 
 

Link to comment
Share on other sites

5 minutes ago, Inform-All said:

Currently this module does not have the option for setting or displaying the origin.

this is an obligation for the commercial invoices in order to post abroad, I am using reference input for this purpose for now.

Many thank you for this module.

Link to comment
Share on other sites

  • 2 weeks later...
On 8/23/2021 at 12:22 PM, korvent said:

Hi, 

My HS Code are different on each of my combinations, do you have any idea how I could add a custom field on combinations instead of products ?

Thanks :) 

This is a good idea!
Might make it in the future, currently i have lot's of paid work so no time to spare. For a small donation fee i can start earlier though.

Edited by Inform-All (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...
On 8/13/2021 at 11:54 AM, Inform-All said:

Added github link in first post.

Thanks for sharing. I want to install your HS Code Module from Github but during upload via Module Manager (PS 1.7.7) I get an error. The version from post #1 is working well. Can you give me a hint for installing modules from your Github. VAT Checker, Order List etc. have the same issue. Maybe I am only to stupid for it.

 

Is there an import available via CSV in HS Code module?

 

Many thanks in advance.

Link to comment
Share on other sites

6 hours ago, KM19 said:

Thanks for sharing. I want to install your HS Code Module from Github but during upload via Module Manager (PS 1.7.7) I get an error. The version from post #1 is working well. Can you give me a hint for installing modules from your Github. VAT Checker, Order List etc. have the same issue. Maybe I am only to stupid for it.

 

Is there an import available via CSV in HS Code module?

 

Many thanks in advance.

If you download the module from Github, you should first open the zip, rename the folder to 'hscodes' and rezip it again.

  • Like 1
Link to comment
Share on other sites

On 9/6/2021 at 7:29 PM, KM19 said:

@Inform-All

Great it works. Is there a method to import HS with a CSV file or something other?

Not yet, there will be a new module version available soon that allows the import of HS codes with the normal Prestashop import method.
But this is a work in progress, i will keep this forum topic updated.

Link to comment
Share on other sites

  • 1 month later...
  • 9 months later...
50 minutes ago, stifler97 said:

Hi. I didnt get what this module is used for?

It is for companies that ship abroad. If you ship products, the customs of the other cou try need a HS code to see what product type is in the package.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...
Just now, St055 said:

I use 1.7.8.7 and it hangs when saving. MySQL +140% of processor. Must restart MySQL server... So I suppose a problem in the code...

Could you elaborate?
Can you share a private message with the queries that are being executed?
Do you have any other product modification modules installed?
How many queries are being executed when the module is not installed? 

It's simply an extension of the product, it's hard to believe that this causes SQL overload.

Link to comment
Share on other sites

I don't know anymore... I just see each time I try to save HS code it hangs all shop... when I type "top" on SSH on my server, MySQL is using huge processor... I've uninstalled it and it works now... So I don't know if it is MySQL related, but there is a problem with the module, for sure...

Link to comment
Share on other sites

1 minute ago, St055 said:

I don't know anymore... I just see each time I try to save HS code it hangs all shop... when I type "top" on SSH on my server, MySQL is using huge processor... I've uninstalled it and it works now... So I don't know if it is MySQL related, but there is a problem with the module, for sure...

So please share more info so can debug for you.
I have 15+ shops (including multistore and PS 1.7.8.7) running this module, i highly doubt it is the module.

Link to comment
Share on other sites

  • 2 months later...
On 12/29/2022 at 2:16 PM, TwinkleEye said:

Hi, where is the donload link for the newest module? 

 

Aslo does it inlucdes both

 

HS

Country of Origin

 

Thanks

The updates will always pushed to Github (here).
But i just updated the initial post with the latest version.

Link to comment
Share on other sites

Hi, I just installed it on Prestashop 1.7.6.4 and it's exactly what I needed !

  • For each product, I can see the HS Code on invoices 👍

Thank you very much for you work ! 

As others, I would like the Country of Origin to appear as 

I had thought of 3 solutions :

  • Make an adaptation of your module HSCode and create CountryCode (2 modules). - I made some tests but I have a problem with the Override.
  • Keep the your HSCode module and adapt it. - I am not a developer and i failed ;-/
  • The third solution would be simple but I would like you opinion.
     

By consulting the code of your module, I saw that you had put an INTEGER field which respects the size of the HS Code.

Example:

return Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'product` ADD `hscode` INT NULL DEFAULT 0');
...
self::$definition['fields']['hscode'] = ['type' => self::TYPE_INT, 'validate' => 'isInt', 'size' => 10];

  <input type="number" name="hs_code" id="hs_code" class="form-control" value="{$hscode}"/>

To avoid a big additional development, would it be possible and "clean" according to you to transform this field in STRING?

return Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'product` ADD `hscode` ISSTRING ...

  self::$definition['fields']['hscode'] = ['type' => self::TYPE_STRING,
...
  <input type="string" name="hs_code" id="hs_code" ...

So instead of entering the HS Code like this: 95030039, we could enter "95030039 CO:FR" for example.

Maybe you won't like this method, but in the end, it would save a lot of development time? 

Not being a developer, I am not able to provide the right code but maybe the reasoning will fit. 

What do you think?

Regards,

Link to comment
Share on other sites

Hi @benisevme

Since @Inform-All upgrade his module, you can print HS code on invoice in the last version.

Not the Origin because it's not implemented on this module.

As you can see, he has updated his post Monday at 08:54 AM by Inform-All with the new version of the module specifying in detail the procedure to add the HS code on the invoice. He also specifies the Github link of his module in this post which will allow you to see possible new versions to come.

Quote

Installation
You can install this module on any Prestashop 1.7 shop.


After installing the module you would have to manually edit the invoice/delivery slip template.
(because Prestashop does not allow this with the module installation)
In the module there is a folder called 'pdf' if you place this folder in your /themes/YOUR-THEME/ folder you are done.

So my previous question was related to this new version and propose a possible modification to add the Country Origin.

Regards,

Link to comment
Share on other sites

About the Country of Origin questions for this module, i could add this to the module, but i don't see why. Just to be clear, this invoice/delivery slip does not have all the requirements of a CN22 or CN23 document ( https://customs-documents.com ).

So if you would like the Country of Origin added, please send me a private message and we can talk about the use case and implementation. :)

@St055 check the installation text in the first post, you have to manually override the files. 

  • Like 1
Link to comment
Share on other sites

Hi @St055,

Did you read the previous post?

Quote

After installing the module you would have to manually edit the invoice/delivery slip template.
(because Prestashop does not allow this with the module installation)
In the module there is a folder called 'pdf' if you place this folder in your /themes/YOUR-THEME/ folder you are done.

 

In others words

1) Installation of module : You've done it.

Until this step, it's will not display you the HS code on invoice. (because Prestashop does not allow this with the module installation)


2) Connect you on your FTP


3) Go on the folder /themes/YOUR-THEME/

Copy the FTP folder of the module "module/hscode" inside the folder /themes/YOUR-THEME/

and it's done !

Regards,

 

 

 

Link to comment
Share on other sites

@St055

Do you have a specific template or Prestashop default template ?

Here is my config on FTP exemple wich is ok for me for a specific template.

2023-01-04_13h57_38.png.d0847f91694f35242eefd013535d7ffe.png

Of course, to check the invoice, you have to complete an order and see if it appears afterwards.

If it's not work, i can't help you more. 😕

Regards,

Link to comment
Share on other sites

  • 1 month later...

I just tried to install this and it installed and all looked well - however when I tried to add a HS Code on a product and hit save it just hung with the "saving wheel" frozen.  Basically unusable - thankfully the module manager wasn't affected and could get to the it and uninstall the module and everything returned to normal. 

Anyone come across this before? 

Link to comment
Share on other sites

On 2/28/2023 at 11:06 AM, technocracy said:

I just tried to install this and it installed and all looked well - however when I tried to add a HS Code on a product and hit save it just hung with the "saving wheel" frozen.  Basically unusable - thankfully the module manager wasn't affected and could get to the it and uninstall the module and everything returned to normal. 

Anyone come across this before? 

Hmmm sounds odd, could you try again and check your browsers console if it brings anything up?

Link to comment
Share on other sites

  • 4 months later...

Hi, pulled the latest version from Github since I need this because the Spanish Postal Services are making a fuss about missing HS codes and countries of origin on intra-european sales. I too would need to be able to add country of origin to this. Quite willing to pay for it as well, how'd we go about this?

Link to comment
Share on other sites

1 minute ago, gorkij77 said:

Hi, pulled the latest version from Github since I need this because the Spanish Postal Services are making a fuss about missing HS codes and countries of origin on intra-european sales. I too would need to be able to add country of origin to this. Quite willing to pay for it as well, how'd we go about this?

I will send you a private message.

Link to comment
Share on other sites

  • 2 months later...
15 hours ago, aitorjp said:

Thanks for this free module! but after installing it nothing has happened in PrestaShop 8.1.2, PHP 8.1.24 and warehouse theme.

No form or tab appears on the BO product page

You are correct, Prestashop made a huge update on product hooks and the extending of Products in PS8.1.

Unfortunately i have not adapted this module yet. This module is "Community paid" meaning if an update/improvement is requested i will make it for a small donation.
So please send me a private message if you are interested in the updated module.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...