Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

E-Commerce Modules /

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, Ed, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba

Weight Based Shipping


Go to End


8 Posts   3049 Views

Avatar
3pointross

Community Member, 19 Posts

8 June 2009 at 11:32am

Has anyone gotten weight based shipping to work?

It looks like you need to use an array to pass the weight and price values, however there is no example code that demonstrates how it should be done?

/**
* Calculates the shipping cost of an order, by taking the products
* and calculating the shipping weight, based on an array set in _config
* ASSUMPTION: The total order weight can be at maximum the last item
* in the $shippingCosts array.
*/

Any clues / ideas?

Thanks in advance
-Ross

Avatar
Digital Punk

Community Member, 51 Posts

15 July 2009 at 3:57am

Did you got ecommerce module working with weight based shipping?

Avatar
Digital Punk

Community Member, 51 Posts

21 July 2009 at 3:22am

I'm tried to put this code in config file:

WeightShippingModifier::shippingCosts(array(
'1' => 15,
'3' => 30,
'5' => 50,
));

but it doesn't worked.

Has anybody ideas or example how to ser weight based shipping?

Avatar
Nicolaas

Forum Moderator, 224 Posts

21 July 2009 at 1:01pm

Hi

So that we can help you, please post a bit more information:

  • what is not working?
  • what error do you get?
  • what version of SS / ecommerce are you running?
  • how do you know you have an error?
  • have you done a dev/build/?flush=1 and cleared all your cookies (important for ecommerce)?

Cheers

Nicolaas

Avatar
Digital Punk

Community Member, 51 Posts

21 July 2009 at 9:08pm

Edited: 22/07/2009 8:59pm

Sorry, here is more information.

When I'm trying to set Weight based shipping array (see code above), I get this error message: Fatal error: Call to undefined method WeightShippingModifier::shippingcosts() in /var/www/vhosts/sandie.dev.bluwcreative.com/httpdocs/mysite/_config.php on line 111

I used class "shippingcosts" because it was on the documentation:

* Calculates the shipping cost of an order, by taking the products
* and calculating the shipping weight, based on an array set in _config
*
* ASSUMPTION: The total order weight can be at maximum the last item
* in the $shippingCosts array."

Maybe this array code is wrong and I should use another class from WeightShippingModifier.php ?

Thanks for any help!

My System:
ecommerce 0.6 beta 1
silverstripe 2.3.2 (stable version)
php 5.2.9
mysql 5.0.83
apache 2

Avatar
Nicolaas

Forum Moderator, 224 Posts

22 July 2009 at 7:45pm

ok, so what you want to do is to find the class WeightShippingModifier and see what static methods are available. I imagine that the module has been changed but that the documentation has not been updated yet. Let us know how that goes.

Avatar
Digital Punk

Community Member, 51 Posts

22 July 2009 at 9:01pm

I didn't found there any static method (see attached file).

Avatar
Nicolaas

Forum Moderator, 224 Posts

22 July 2009 at 9:25pm

those modifiers actually dont make any sense....

have a look here:
http://open.silverstripe.com/browser/modules/ecommerce/trunk/code/modifiers/SimpleShippingModifier.php

and here:
http://open.silverstripe.com/browser/modules/ecommerce/trunk/code/modifiers/WeightShippingModifier.php

I think you will have to write your own shipping modifier for the time being as they seem incomplete. Simple Shipping M. makes a good start and so does Weight Shipping, but you really need a combination of the two. It makes me wonder if the WSM should actually extend the SimpleShippingModifier.

You would be better off writing your own modifier using ideas from those two files.

Cheers

Nicolaas