Print

If you have the need to sell services or products via Virtuemart that don't require shipping then you are out of luck with Virtuemart out of the box.  However with a few simple tweaks to the VM codebasee this can be accomodated.

Virtuemart has a very helpful mechanism for creating downloadable products which we can adapt to skip the shipping step of the checkout.

Code Changes

If you edit the file administrator/components/com_virtuemart/classes/ps_product.php and find the method "is_downloadable" (line 945 in Virtuemart 1.15) and replace it with the following code

	function is_downloadable($product_id) {
		// GWE mod start
		if( empty( $GLOBALS['product_info'][$product_id]['skipshipping'] )) {
		    $db_check = new ps_DB;
			$q_ns = 'SELECT p.product_id from #__{vm}_product as p
					LEFT JOIN #__{vm}_product_category_xref as xr on  p.product_id=xr.product_id
					LEFT JOIN #__{vm}_category as ct on  xr.category_id=ct.category_id
					where p.product_id='.intval($product_id).' AND LOWER(ct.category_name) = "no shipping"';

			$db_check->query($q_ns);
			$db_check->next_record();
			if( $db_check->num_rows() > 0 ) {
				$GLOBALS['product_info'][$product_id]['skipshipping'] = 'Y';
			} else {
				$GLOBALS['product_info'][$product_id]['skipshipping'] = 'N';
			}
		}
		// GWE mod end
		if( empty( $GLOBALS['product_info'][$product_id]['is_downloadable'] )) {
		    $db_check = new ps_DB;
	        $q_dl = "SELECT attribute_name,attribute_value 
	        				FROM #__{vm}_product_attribute WHERE
							product_id=".(int)$product_id." AND attribute_name='download'";
			$db_check->query($q_dl);
			$db_check->next_record();
			if( $db_check->num_rows() > 0 ) {
				$GLOBALS['product_info'][$product_id]['is_downloadable'] = 'Y';
			} else {
				$GLOBALS['product_info'][$product_id]['is_downloadable'] = 'N';
			}
		}
		// GWE mod start
		//return $GLOBALS['product_info'][$product_id]['is_downloadable'] == 'Y';
		return ($GLOBALS['product_info'][$product_id]['is_downloadable'] == 'Y' || $GLOBALS['product_info'][$product_id]['skipshipping'] == 'Y');
		// gwe mod end
	}

Creating Non-Shipping Products

If you look at the code above you may notice that there is a test on a product's category name.  Basically any product we create if we add it into a category called "No Shipping" then in combination with the code change above Virtuemart will skip the shipping stage of the checkout process.