News:

Looking for documentation? Take a look on our wiki

Main Menu

Shipping method by weight and free shipping amount

Started by ukoo.fr, May 01, 2009, 15:26:32 PM

Previous topic - Next topic

ukoo.fr

Hello,
After some hours spended to find a solution about this case i decided to post the answer :

Shipping methods needed :
****************
Shipping cost basis : 0.00€ > 150.00€ = 12 €
Free Shipping over 150.00 € for an order total weight under 30.00kg

And
30 to 40 Kg : 15 €
40 to 50 Kg : 26 €
50 to 60 Kg : 37 €

Solutions :
****************
At first you need to set your Virtuemart-Config also on
// Shipping modules :

- Shipvalue activate only for oders under 30.00kg
settings
Order total value 1 amount to 150.00 / 12.00
Order total value 1 amount to 10 000.00 / 0

- Standard shipping activate
set your differents shipping rates :
0 to 30kg
30 to 40kg
40 to 50kg
50 to 60kg

// Now the core hack :
administrator / components / com_virtuemart / classes / shipping / shipvalue.php

1
at line 33
replace       
Quote/** Read current Configuration ***/
      require_once(CLASSPATH ."shipping/".$this->classname.".cfg.php");

by       
Quote/** Read current Configuration ***/
      require_once(CLASSPATH ."shipping/".$this->classname.".cfg.php");
require_once(CLASSPATH. 'ps_checkout.php' );
global $weight_total;


2
above line 82

add just after
Quoteif($order_total < $base_ship2) {

Quoteif ($weight_total <= 30) {   

         $flat_charge2 *= $taxrate;
         $shipping_rate_id = urlencode($this->classname."|STD|Standard Shipping under ".$base_ship2."|".$flat_charge2);
         $html = "<br />";
         $html .= "\n<input type=\"radio\" name=\"shipping_rate_id\" checked=\"checked\" value=\"$shipping_rate_id\" id=\"$shipping_rate_id\" />\n";
         $html .= "<label for=\"$shipping_rate_id\">Special Shipping price for this order : ".$CURRENCY_DISPLAY->getFullValue($flat_charge2).'</label>';
         $_SESSION[$shipping_rate_id] = 1;
}
else {
30 is our weight-limit to display this shipping method




Now we can go to administrator / components / com_virtuemart / classes / shipping / standard_shipping.php and replace at line 101 by
Quote
            if( ! $selected ) {
               $selected = True ;
               $html .= "" ;

I have done that to preselect the first method (shipvalue) by default on checkout process.


Hope this little hack can help someone ;-p


Some nice works on : http://www.ukoo.fr