Jump to content

ShippingModule support - Patch


AU_Allan
 Share

Recommended Posts

Late last year I was annoyed by not being able to simply download or write a shipping module and have it work without modifying code.

Why should you have to butcher Prestashop to get a shipping module installed only to find it useless for future versions?

My goal for this addition was to add support for shipping modules with little modification to the Prestashop code in the hope that others without much PHP knowledge could benefit. Who knows one day maybe it, or something similar, could be combined into Prestashop.

This patch enables shipping modules to be dynamically loaded using the Prestashop module mechanism. I have provided an Australia Post module (My initial need for a shipping module) and a sample module to help others develop modules using this mechanism.

This was initially written for v1.2.5 however I have modified and tested it to run on the latest Prestashop v1.3.1 code.

Instructions on installation and full details are in the files:

http://nutrino.com.au/code/prestashop/shipping_module_support_v0.15.tar.gz - Patch for Prestashop v1.3.1 and sample module
http://nutrino.com.au/code/prestashop/shippingaustpost_v0.1.tar.gz - Australia Post Shipping Module (Requires Above)

NOTE: I have patched Prestashop v1.3.1 due to the problems below of people being unable to apply the patch (in windows mainly). I have also modified the SQL files so that the database changes will be completed during the install. You should just need to use the standard prestashop install procedure.
The code is available at:
http://nutrino.com.au/code/prestashop/prestashop_1.3.1_shipping_patch_applied.zip
http://nutrino.com.au/code/prestashop/prestashop_1.3.2.3_shipping_patch_v0.15_applied.zip (Updated 24 Oct 2010)
http://nutrino.com.au/code/prestashop/prestashop_1.3.5.0_shipping_patch_v0.15_applied.zip (Updated 06 Jan 2011)

Let me know if you like and I'll try to maintain it.
-Allan.

Share this post


Link to post
Share on other sites

  • 1 month later...

Hi,

First of all thank u so much Allan for the module, I really appreciate it.

I have installed the module as per your instruction however it seems to erase my list of modules (in the module tabs)

The following are the steps I have used to install the module:

1. Downloaded the module
2. Uploaded the module in "modules folder"
3. When I go back to the module section- the list of all my modules disappear
3. Copied your patch, therefore overwriting the original files
4. Unfortunately no luck! :(

If you can help me I would greatly appreciate it as I am struggling to death trying to setup my shop.

Andy help will be truly appreciated.

Thank You
Khushi

Share this post


Link to post
Share on other sites


I have installed the module as per your instruction however it seems to erase my list of modules (in the module tabs)

The following are the steps I have used to install the module:

1. Downloaded the module
2. Uploaded the module in "modules folder"
3. When I go back to the module section- the list of all my modules disappear
3. Copied your patch, therefore overwriting the original files
4. Unfortunately no luck! :(


Khushi,

That sounds to me as if PHP is having an issue somewhere.

The problem you describe I have only observed when the ShippingModule.php is missing from the classes directory and/or the patch has not been applied successfully. This is what will be happening in your 'Step 3' however applying the patch using the 'patch' command should modify your Prestashop instance and allow the module to work.

Did you follow the steps in the release notes?
# Backup your data!!!
While these steps shouldn't do anything bad, you can never be too careful!
# Run the following SQL on your database
# Patch your code, there should be no conflicts.
# Write/Install Shipping modules...

During the last couple of weeks I have been going through and checking the various additional features that I have for Prestashop against v1.3.1 during my testing I found a problem with the ShippingModule patch when using the 'PriceByPrice' in a Carrier, which I do not use on my stores. I have fixed the issue and a new version is available at:
http://nutrino.com.au/code/prestashop/shipping_module_support_v0.15.tar.gz

You can reverse the patch using the '-R' option in the patch command or by running 'patch -p1 -R < 1.3.1_shiping_module_support_v0.1.patch' after you have done this the only thing you will need to do is apply the new .patch file. You may also wish to check normal functionality before applying the new patch, just to make sure you dont make things worse.

I don't think the these changes will fix your problem as I only experienced it when displaying the cart on the front office pages with the condition above, however if you still experience problems after can you please provide me with some details on your Prestashop install so that I can investigate further?

Things that would be helpful:
# What version of Prestashop are you running?
# What version of PHP are you currently using (run 'php -v')
# What operating system are you hosting it on?
# Are you able to access the error log? If so can you post the lines that appear in it when accessing the modules page.
# Did you follow the instructions in the release notes?
# Did you update your database?
# Have you made any other changes to the code before applying the patch?

Thanks!

Share this post


Link to post
Share on other sites

Hi allan,

yeah Ive got the same issue, had it the shop on hostgator, then had this issue decided to stick it on my netregistry server still striking out.
payments and the modules screens go blank as soon as the folder is uploaded. this is testing on brand new unmodified clean sites

the module window comes up with only

* Positions
Back Office >> Modules

payment window comes up with the
* Currencies
* Taxes
* Vouchers
but no breadcrumbs nav

searched the other thread on here about blank windows, couldnt find a solution that worked

PrestaShop 1.3.1
phpMyAdmin 2.6.4-pl3
MySQL 5.0.51a-24+lenny4
OS windows
no error log
instructions followed word for word on both hostgator and netregistry systems (including with the old and new patch)
no updates
no changes to the code

Share this post


Link to post
Share on other sites


PrestaShop 1.3.1
phpMyAdmin 2.6.4-pl3
MySQL 5.0.51a-24+lenny4
OS windows
no error log
instructions followed word for word on both hostgator and netregistry systems (including with the old and new patch)
no updates
no changes to the code


Thanks for the additional information. I have not tested this on a windows system. I'm assuming that you are running IIS? I will attempt to replicate the problem in windows and post the results.

If you can give me any additional details about your hosting setup that may help in reproducing the fault that would be great.

Do you know what PHP version you are running?
Can you confirm that the classes/ShippingModule.php file exists?

Share this post


Link to post
Share on other sites

I can confirm that the changes work successfully under Windows Server 2008 with IIS 6.0 SP1 and PHP v5.2.6

The problem you describe is most likely due to the patch not being applied correctly and/or the classes/ShippingModule.php file missing. Can you please provide me with the following files from your prestashop directory so I can investigate further?

classes/ShippingModule.php
classes/Hook.php
classes/Carrier.php
order.php

Share this post


Link to post
Share on other sites

Hi
I think I incorrectly installed your shipping module or there's an error with it. I have pasted my error log. Can you look into it please?
Thankyou :)

http://www.prestashop.com/forums/viewthread/71419/P15/configuring___using_prestashop/no_modules_please_help

Warning: require_once(/chroot/home/thebeaut/thebeautyelements.com.au/html/config/../classes/ShippingModule.php) [function.require-once]: failed to open stream: No such file or directory in /chroot/home/thebeaut/thebeautyelements.com.au/html/config/config.inc.php on line 18

Fatal error: require_once() [function.require]: Failed opening required '/chroot/home/thebeaut/thebeautyelements.com.au/html/config/../classes/ShippingModule.php' (include_path='.:/usr/share/pear:/usr/share/php') in /chroot/home/thebeaut/thebeautyelements.com.au/html/config/config.inc.php on line 18 

Share this post


Link to post
Share on other sites

Can you confirm that the file classes/ShippingModule.php in your web server directory.

This issue was seen (as above) due to the patch not being applied correctly and I'm assuming that your having the same issue.

Also can you include the output from the 'patch' command?

Hi
I think I incorrectly installed your shipping module or there's an error with it. I have pasted my error log. Can you look into it please?
Thankyou :)

http://www.prestashop.com/forums/viewthread/71419/P15/configuring___using_prestashop/no_modules_please_help

Share this post


Link to post
Share on other sites

I have edited the first post with a URL to the 'prestashop_1.3.1.zip' file containing the patched files and updated SQL files so that you do not need to modify the code or database yourself. The only thing you need to do now is copy the shipping module into the shipping module directory and you should be up and running.

Share this post


Link to post
Share on other sites

I do not have shell access, therefore I cannot run the PATCH command.
Any idea of how I should proceed?
Cheers,


The easiest way is to download the code (in first post) with the patch already applied. In this code the database changes are made during the install process.

Alternatively you can patch the code on another machine, upload the files, run the install, modify your db and then you should be ok.

Share this post


Link to post
Share on other sites

PrestaShop v1.4 has a new CarrierModule interface, so it should be easier to create shipping modules. It has the following functions:

abstract function getOrderShippingCost($params,$shipping_cost);    
abstract function getOrderShippingCostExternal($params);    

Share this post


Link to post
Share on other sites

  • 1 month later...

Hi Allan,
I have got the same problem as dt88 and Khushi.
Can you please assist me?
This is my first time using prestashop and I am not used to with programming and database.

My details are:
1. PrestaShop 1.3.2
2. php 5
3. Linux os
4. No error
5. Yes
6. No update
7. No changes

Your help will be much appreciated.

Cheers

34412_ImY7neStECQDA8Ly01x4_t

Share this post


Link to post
Share on other sites

PrestaShop v1.4 has a new CarrierModule interface, so it should be easier to create shipping modules. It has the following functions:

abstract function getOrderShippingCost($params,$shipping_cost);    
abstract function getOrderShippingCostExternal($params);    



Thanks rocky for the update! I had a look some time ago and the Shipping module support in v1.4 was non existent. And when you posted the information it was not functional.

I have plans to investigate it further now that the bugs/implementation have been worked out in the hope to modify my code, or roll the v1.4 changes into a patch for v1.3, so that modules can be used with both versions.

Share this post


Link to post
Share on other sites

  • 4 weeks later...
Hi Allan,
I have got the same problem as dt88 and Khushi.
Can you please assist me?
This is my first time using prestashop and I am not used to with programming and database.

My details are:
1. PrestaShop 1.3.2
2. php 5
3. Linux os
4. No error
5. Yes
6. No update
7. No changes

Your help will be much appreciated.

Cheers


Could anyone please help me...
How to restore the list of modules (in the module tabs)

Thank You very much for you help

Cheers

Share this post


Link to post
Share on other sites



Could anyone please help me...
How to restore the list of modules (in the module tabs)

Thank You very much for you help

Cheers


Please look at post #18


My advice is to use the http://nutrino.com.au/code/prestashop/prestashop_1.3.2.3_shipping_patch_v0.15_applied.zip code with the patch already applied.


Dear Allan,
Thank you for your prompt reply,
But how can i apply the module if the list of module in my admin page is empty.
Can anyone please help to restore it?
Below is the image of the module page in my admin.
Thank you very much.

Cheers

Share this post


Link to post
Share on other sites



Dear Allan,
Thank you for your prompt reply,
But how can i apply the module if the list of module in my admin page is empty.
Can anyone please help to restore it?
Below is the image of the module page in my admin.
Thank you very much.

Cheers


As I said in my original post looks as if you have not applied the patch correctly or at all.

To restore your module list remove any shipping modules that you copied to your modules directory and Prestashop will behave as normal.

Share this post


Link to post
Share on other sites

Thank You very much Allan.
I have removed any shipping modules and applied your patch.
Now, what is the next step?
Is there anything that needs to be configured?


The patch allows the shipping modules to work... If you do not apply the patch correctly then when you copy a shipping module into the modules directory the modules list will not be visible in the back office of Prestashop. Which is the problem a lot of people have had.

If you have followed the instructions in the readme that came with the patch, or used the already patched version then you should now be able to copy the module into your modules directory and install it from the modules tab.

The Australia Post shipping module that I created also contains a readme with steps on how to install and configure it.

Share this post


Link to post
Share on other sites

  • 3 weeks later...

Hi Allan,

I've installed the 1.3.5 already patched version successfully. I've also chosen Australia Post Express as the only carrier by unchecking the other options. I've set up a test customer record with a valid address postcode. The problem I am having at the moment is that shipping cost is always free! Any idea why it's so?

Thanks.

Share this post


Link to post
Share on other sites

Hi Allan,

I've installed the 1.3.5 already patched version successfully. I've also chosen Australia Post Express as the only carrier by unchecking the other options. I've set up a test customer record with a valid address postcode. The problem I am having at the moment is that shipping cost is always free! Any idea why it's so?

Thanks.


By default Prestashop is set to have orders >$20 (From memory) to have free shipping, change the value to 0 and it should work.

To find it click the 'Shipping' tab in the backend and then look for 'Free shipping starts at:' There is also 'Free shipping starts at:' which may be set.

Hope that helps!

Share this post


Link to post
Share on other sites

Thanks for putting together this module, love your work! Found the code very easy to read and understand.

I was getting some weird pricing results when testing, where it seemed to ignore the weight I had set for products and was calculating them all at 500grams, (which was the default if no weight was set).

If you look at line 289 of the shippingaustpost.php file it refers to $product['weight_attribute'] which I think should just be $product['weight'] - possibly a change with prestashop (i'm running 1.3.2)

ie.

$product_weight = $product['weight'] * $this->weight_adjustment;



Making this minor update worked a charm, hope it helps if anyone else is having the same issue.

Cheers,
Katrina.

Share this post


Link to post
Share on other sites

  • 2 months later...

Hi Allan...or any one who can answer...
How exactly do I run/execute the patch?
Through command prompt?
Where you have @prestashop and @prestashop prestashop below, these refer to my stores root folder but prestashop prestashop can't figure out.
Do I remove the square brackets?

[[email protected] ~]# cd prestashop/
   [[email protected] prestashop]# patch -p1 < 



I already have store themed and catalog loaded so can't use the install with patch already loaded.

Sorry it is something I never have had to run being design based.
Thanks in advance

Share this post


Link to post
Share on other sites

  • 2 months later...

Anyway anyone can update this for version 1.4 or point me in the direction on how to upgrade this module for 1.4?

Looks fantastic I might even revert my prestashop version to an earlier version if there are no solutions.

I have seen the paid for ones but they are way too expensive for such a little store that I will be offering.

Thanks.

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More