Savage Posted October 28, 2002 Posted October 28, 2002 Hi, I got a problem with the shippingmodules. The post office here in norway uses 36 NOK in handling fee, and usually 86 NOK in shipping. We pay the shipping if they order for more then 800 NOK, but we don't pay for the handling fee. Is there a way to sort out this automatically?
Ajeh Posted October 28, 2002 Posted October 28, 2002 Basically you sound like you are using a flat rate system with a handling fee where if the $total cart < $XX charge the shipping rate and handling fee and if > $XX charge just the handling fee. If you are not altering the shipping per order, base this off of flat rate. If you are altering the shipping per order on $total < $XX then modify this so the shipping module that calculates this rate shows when orders are $total < $XX otherwise, the flat rate shipping module shows. The easiest way to determine which to show is to edit the shipping modules and set up a true or false condition based on $total in the class construction If ( $$cart->show_total() <= $800 ) { $this->enabled = MODULE_SHIPPING_FLAT_STATUS; } In the other shipping module, set it up the other way. This will make only one or the other shipping module appear at checkout
Savage Posted October 28, 2002 Author Posted October 28, 2002 I dont quite get it. Where in the flat.php am i suppose to add that code?
Ajeh Posted October 28, 2002 Posted October 28, 2002 The current code: // class constructor function flat() { $this->code = 'flat'; $this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE; $this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION; $this->icon = ''; $this->enabled = MODULE_SHIPPING_FLAT_STATUS; } You need to set the IF statement around the enabled definition. If that is not enabled, then the shipping method will not show. Try this ... turn on flat.php and look to make sure you see it in a checkout Now edit flat.php with a simpe IF: if (false) { $this->enabled = MODULE_SHIPPING_FLAT_STATUS; } Basically that just turned it off. So upload it and hit checkout again. flat will no longer be there. Now, change to this simple test: if (true) { $this->enabled = MODULE_SHIPPING_FLAT_STATUS; } Upload and hit checkout ... flat is back. So the idea is to set up a condition here based on your needs. When should flat.php show? That IF statement can test any condition you like and that will toggle it on/off based on the current order status automatically for you. Then, you setup another shipping module, basically in the same way that is to handle the other shipping condition. Now, only one or the other shipping module will show based on the $total order amount. Clear as mud? :shock:
Savage Posted October 28, 2002 Author Posted October 28, 2002 Ah, even I could understand that.. not bad uh? Thanks a lot, I'll give it a go!
Savage Posted October 28, 2002 Author Posted October 28, 2002 Okay, here's the thing: I added the code you wrote earlier in flat.php like this: function flat() { $this->code = 'flat'; $this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE; $this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION; $this->icon = DIR_WS_ICONS . 'posten.gif'; If ( $$cart->show_total() <= $800 ) { $this->enabled = MODULE_SHIPPING_FLAT_STATUS; } } but that just gave me this error msg: Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /home/petronas/www/futurenet/maxkopp/catalog/includes/modules/shipping/flat.php on line 22 Fatal error: Cannot instantiate non-existent class: flat in /home/petronas/www/futurenet/maxkopp/catalog/includes/classes/shipping.php on line 29 Line 22 in flat.php is: If ( $$cart->show_total() <= $800 ) { Line 29 in shipping.php is: $GLOBALS[$class] = new $class; Got any ideas?
Ajeh Posted October 28, 2002 Posted October 28, 2002 oops ... that is $cart->show_total() not $$cart->show_total() ... there is an extra $ in there :shock: One other thing you need ... Right at the top of the function: Add this global statement so you can read that variable ... function flat() { global $cart;
Savage Posted October 28, 2002 Author Posted October 28, 2002 Great, thanks a lot.. It actually worked :D oh, I needed to remove the $ in front of 800 too... But thanks a lot again! You just made my day :wink:
Recommended Posts
Archived
This topic is now archived and is closed to further replies.