Customize VirtueMart shipping rate calculation

Discussion in 'eCommerce' started by Webed4it, Apr 11, 2011.

  1. #1
    Hi guys

    I have a situation where I'm using VirtueMart and some products are very big so they need to be shipped as a separate package while the other products are small enough to be shipped together or with one big product.

    I can't find a shipping module that would do that so I wrote some code to try and adapt the standard shipping module. I added this code to the end of (just before the return statement) the get_rate_details function in /public_html/administrator/components/com_virtuemart/classes/shipping/standard_shipping.php but it does not make a difference even though the standard shipping module is enabled. Can anyone please tell me where to put this code or any other way to do this.

    $big_products = 0 ;
    		for( $i = 0 ; $i < $cart["idx"] ; $i ++ ) {
    			$tsku = $cart[$i]["product_sku"]; //current sku or product id
    			if ($tsku == 'KG1' || $tsku == 'KG2' || $tsku == 'KG3' || $tsku == 'KG4' || $tsku == 'WMS1' || $tsku == 'MJ1')
    			{
    			$big_products += 1;
    			}
    		}
    		if ($big_products > 0)
    		{
    		$rvalue += 36.55 * ($big_products - 1); //postal rate for extra package times number of extra big products
    		}
    Code (markup):
     
    Webed4it, Apr 11, 2011 IP