Subscribe via RSS

Virtuemart Free Shipping For Shopper Group

Today I searched how to allow free shipping for a specific shopper group in the Virtuemart shopping cart. There was a shopper group extension in development for this, but it does not work with our 1.1 version of Virtuemart.

I decided to dive into the source code and tackle the problem on my own. Below are the details of how to implement this on your Virtuemart system should you have need.

The first thing I did was added a column to the shopper group table. This will flag the shopper group to have free shipping in the cart if you so desire.

/*You may have to alter the table name if your prefix does not start with jos_vm_ which is the default*/
ALTER TABLE `jos_vm_shopper_group` ADD COLUMN `shopper_group_freeshipping` TINYINT(1) UNSIGNED AFTER `default`;

There is on PHP file that must be edited. It is located in the following folder under your Joomla installation directory.
\administrator\components\com_virtuemart\classes\ps_checkout.php

At or around line 63 you will see the following if statement

if($vendor_freeshipping > 0 && $vars['order_subtotal_withtax'] >= $vendor_freeshipping) {

That line needs to be replaced with the following

		$db = new ps_DB();
		$q = 'SELECT shopper_group_freeshipping from #__{vm}_shopper_vendor_xref xref
			inner join #__{vm}_shopper_group shopper on xref.shopper_group_id = shopper.shopper_group_id
			where xref.user_id = ' . $_SESSION['auth']["user_id"];

		$db->query($q);
		$db->next_record();
		$free_shoppergroup_shipping = $db->f('shopper_group_freeshipping') == 1;
		//original line at 63
		if(($vendor_freeshipping > 0 && $vars['order_subtotal_withtax'] >= $vendor_freeshipping) || $free_shoppergroup_shipping) {

A little bit further down there is this if statement

if(empty($_REQUEST['ship_to_info_id']) && ps_checkout::noShipToNecessary()) {

$db = new ps_DB();

You can comment out or remove the $db = new ps_DB();. It is now already being instantiated due to our new code.

There is nothing else that needs to be changed. You will have to manually flag shopper groups in the db using the new shopper_group_freeshipping column that was added. This should have a value of 1 for any shopper groups that need to get free shipping. All other groups can have a value of NULL or 0 to get the standard shipping you have configured in your installation.

I will make another post if I tackle adding a checkbox on the shopper group to update this field. If anyone else does it please let me know and I will post your code or provide a link to your blog.

Joomla Template Different Header on Pages

Today I Searched joomla template different header on pages for a good solution to display a different header image for a couple of pages for a joomla website. I found this page http://www.alledia.com/blog/design/different-header-images-on-different-pages/ that referred to a module that could be installed, Header Image, that would do exactly what i wanted.

Header Image is a flexible module able to display context related images, media or other files. Based on the context of the current displayed Joomla Content, that is the ID’s of section, category, item and content, the module selects a corresponding image or media file to display.

Header Image was removed from free joomla repository and is only available from their website. The non-commercial version is free and the commercial version is 39 euros.

It was super easy to get up and running. Just download Header Image from there website and install it using the extension manager. Then add the extension to the position you want your images to display at in your template. Set up your default folder with the images you want to display and then name with according to your rules. For example I wanted my images to display according to there article ID so i named my images CI55.gif where 55 is the article id. I also set a default image that will display if no matches are found.

This module is a lot more powerful than just displaying a single image on a single page. It can also do slide shows and you can get more advanced in your image naming for a more dynamic headers based on section, category and content.