Post by rofus » Mon Oct 03, 2011 9:05 pm

Hi all,

for my shop I needed to duplicate the weight based shipping module. I know Qphoria suggested several times that is not needed because that module is based on geozones and I can create how many I want with different prices.

In my case I needed to make other code calculations (different from the main weight based shipping module), so I needed two different weight based shipping modules to offer different rates and different calculations added in the module code.

I followed instructions, duplicated all relevant catalog and admin pages, I successfully created the new rates in the admin of the duplicated module, and they are recorded properly in the 'setting' table (group 'weight', key 'weightInsured_').

Testing it on the main store is works ok doing all the calculations correctly at checkout, but when I select this 'second' weight based module (that I use for particular insured shipping we offer) as shipping method and I click 'Continue', I receive a general 'shipping_error' on top. No other error also in logs.


In other posts someone suggested that there's some function in OC core code that expect the values with key 'weight_', so receiving something like 'weightInsured_' breaks the thing. Is there someone that can point me to where this function is so I could try fix it as well to accept my 'weightInsured_' key?


Thanks.
Last edited by rofus on Wed Oct 12, 2011 11:28 pm, edited 1 time in total.

New member

Posts

Joined
Wed Feb 09, 2011 10:28 pm

Post by Qphoria » Mon Oct 03, 2011 11:44 pm

well in this case you are changing functionality.. its not a clone of the same module.. its just similar module with different code.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by rofus » Tue Oct 04, 2011 12:02 am

Hi Qphoria,

yes your definition is more appropiate :) As I said it's very odd..it works perfectly and makes all calculations correctly, I modified the module so that it shows on screen more informations like the weight of each single product type in the cart and some debug for me as well).

The only problem I get is that when I want to select my own 'weight based' shipping method (it always works based on weight and geozones), I get this general 'shipping_error' message...do I have a way to have a more verbose error message so I can understand where the problem is? I just don't know where to look without a proper error message..

Thanks as always if you can help.

New member

Posts

Joined
Wed Feb 09, 2011 10:28 pm

Post by rofus » Mon Oct 10, 2011 8:04 pm

Anyone with suggestions about how to correct this? The duplicated weight module works, stores all his values correctly from admin (I changed the prefix from weight_ to weightInsured_), and on checkout page calculates correctly rates. But if I select it (instead of the original weight module) as a shipping method, I get a general 'shipping_error' message.

Any way to have on screen a complete error log or any suggestion to what to checkout? I suspect the weight module passes some $weight value to some outside core function, and probably some problem arises if I pass $weightInsured ? Any idea or possible suggestion ?

Thanks as usual!

New member

Posts

Joined
Wed Feb 09, 2011 10:28 pm

Post by rofus » Wed Oct 12, 2011 11:28 pm

If interesting for someone..I just fixed the problem.

What I did is duplicate the base weight based shipping module because I needed another shipping method, with a base calculation based on geo_zones like in the normal weight based shipping module, plus different calculations with base prices and added fees (both fixed and geo_zone based) for insurance.

I needed all this added to the normal weight shipping module, so I successfully duplicated the module and relative admin pages, and all was working well. At the checkout, when selecting the shipping method, I saw both shipping methods with the correct calculations displayed, but selecting the 'duplicated' shipping method I got an 'error_shipping' generic error.


After some hours of inspecting and going back in the code, I disovered that my duplicated module was working with weightInsured_ base key (original one is weight_), but the 'id' posted (in the model/shipping/weightInsured.php and in controller/checkout/shipping.php) was still as 'weight', and in the database table 'setting' the values of the duplicated module were stored as group 'weight' (that I thought was ok).

I modified it all so that now all the settings for my duplicated module have the group 'weightInsured', and the 'id' and prefixes in the checkout shipping.php page and in module is not anymore 'weight' but 'weightInsured'.

All works perfectly and flawlessy, hopefully this will be useful for anyone else wanting to create a new shipping method based on the weight based one already in Opencart (I work on 1.4.9.6).

New member

Posts

Joined
Wed Feb 09, 2011 10:28 pm
Who is online

Users browsing this forum: No registered users and 1 guest