virtuemart Archives | Lee Willis https://www.leewillis.co.uk/tag/virtuemart/ Wed, 09 Jun 2010 20:36:32 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.1 Extending Virtuemart the smart way https://www.leewillis.co.uk/extending-virtuemart-the-smart-way/ https://www.leewillis.co.uk/extending-virtuemart-the-smart-way/#respond Thu, 10 Jun 2010 18:00:44 +0000 http://www.leewillis.co.uk/?p=276 Someone left a comment on my article about Virtuemart Category Discounts the other day – that I though was worthy of a post of its own. What James pointed out was that instead of amending core files, you can create … Continue reading

The post Extending Virtuemart the smart way appeared first on Lee Willis.

]]>
Someone left a comment on my article about Virtuemart Category Discounts the other day – that I though was worthy of a post of its own.

What James pointed out was that instead of amending core files, you can create “class overrides” to amend functionality you want to.

You can read James’ original comment, or skip straight to the article that explains everything!

My future Virtuemart customisations will definitely make use of this – thanks James!

The post Extending Virtuemart the smart way appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/extending-virtuemart-the-smart-way/feed/ 0
Adding Virtuemart Product Images to your Sitemap https://www.leewillis.co.uk/virtuemart-product-images-sitemap/ https://www.leewillis.co.uk/virtuemart-product-images-sitemap/#comments Wed, 28 Apr 2010 20:58:28 +0000 http://www.leewillis.co.uk/?p=266 I wrote in a recent post about how to add post images into your sitemap based on WordPress post images. However I look after a couple of sites, and they’re not all WordPress. So I set off on a quest … Continue reading

The post Adding Virtuemart Product Images to your Sitemap appeared first on Lee Willis.

]]>
I wrote in a recent post about how to add post images into your sitemap based on WordPress post images. However I look after a couple of sites, and they’re not all WordPress. So I set off on a quest to add images to sitemaps on my Joomla! sites.

The good news is that my sitemap plugin of choice, Xmap, had recently added basic image support to their XML sitemaps. However, while Xmap can generate sitemaps for a wide variety of Joomla! components – the only one to have image support currently is the standard com_content extension. One of my main Joomla! sites though is a store based on Virtuemart, and I wanted to add product images to the sitemap.

The result is a revised version of the com_virtuemart extension for Xmap, and a small change to the Xmap XML output code.

To get things up and running there’s five simple steps:

  1. Make sure you’re running version 1.2.7 of Xmap
  2. Take backups of all of these files from your existing Joomla! installation:
    • components/com_xmap/xmap.xml.php
    • administrator/components/com_xmap/extensions/com_virtuemart.xml
    • administrator/components/com_xmap/extensions/com_virtuemart.php
  3. Download com_virtuemart.xml and com_virtuemart.php from here, and save them into administrator/components/com_xmap/extensions/
  4. Download xmap.xml.php from the same place, and save it into components/com_xmap/
  5. Configure the com_virtuemart extension under com_xmap settings in your Joomla! administrator area. Make sure you’ve got images turned on, and a license URL specified if you want one.

That’s it – your sitemap should now include images for all of your products.

PS. The default Joomla! robots.txt bans Googlebot from crawling the Virtuemart image folders, you can allow them, by adding:

Allow: /components/com_virtuemart/shop_image/product/

to the bottom of your robots.txt …

The post Adding Virtuemart Product Images to your Sitemap appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/virtuemart-product-images-sitemap/feed/ 11
Featured Products With Virtuemart https://www.leewillis.co.uk/featured-products-virtuemart/ https://www.leewillis.co.uk/featured-products-virtuemart/#comments Wed, 06 May 2009 21:09:35 +0000 http://www.leewillis.co.uk/?p=61 Featured Products e-Commerce stores often want to highlight a particular product or products. This can because they have new products to promote, special offers, stock to clear – or just because they believe it will help conversion. While the popular … Continue reading

The post Featured Products With Virtuemart appeared first on Lee Willis.

]]>
Featured Products

e-Commerce stores often want to highlight a particular product or products. This can because they have new products to promote, special offers, stock to clear – or just because they believe it will help conversion.

While the popular Virtuemart e-commerce system will let you mark products as “On Special”, it doesn’t offer an out-of-the box way to highlight these special products on the main shop pages.

This article will show you how you can use this “On Special” functionality to implement “featured products” in your product listing pages on your Virtuemart Site – take a look at the example below:

Featured Baby Carriers

Standard Functionality

The standard Virtuemart functionality allows you to set a product as “On Special” – as the image below shows.
Setting the On Special Flag
Unfortunately, this information about your products isn’t available to your theme, so you can’t style your products differently, nor can you sort them to the top of your list (As most designs would require).

Getting the information

The first thing we need to do is make sure that the details about whether the flag is set or not is pulled back from the database. The file we’re interested in is shop_browse_queries.php which is in administrator/components/com_virtuemart/html/.

Line 39 specifies a variable called $field_names, so we need to add the database field product_special to this list, e.g.

shop_browse_queries.php – Line 39:
$fieldnames = "`product_name`, `products_per_row` , `category_browsepage` ,
`category_flypage` , `#__{vm}_category`.`category_id` ,
`#__{vm}_product`.`product_id` , `product_full_image` , `product_thumb_image` ,
`product_s_desc` , `product_parent_id` , `product_publish` ,
`product_in_stock` , `product_sku` , `product_url` ,
`product_weight` , `product_weight_uom` , `product_length` ,
`product_width` , `product_height` , `product_lwh_uom` ,
`product_in_stock` , `product_available_date` ,
`product_availability` , `product_special`,
`#__{vm}_product`.`mdate` ,  `#__{vm}_product`.`cdate`";

We then need to make sure that this information is added to the product array available to the layout code.

shop.browse.php – Line 450:
$products[$i]['product_special'] = $db_browse->f("product_special");

Now, in your browse page template, you can simply check the value of $product_special, and change your HTML output accordingly. For example, on SnugBaby, we wrap featured products in a styled div:

<?php if ($product_special == 'Y') : ?> <div class="featuredheading"> <h3>Featured Product</h3> </div> <div class="featured"> <?php endif; ?>

Bubbling up…

So far we’ve managed to highlight featured products, and the next change is a bit take it or leave it. However, when we were doing our implementation of this on SnugBaby we decided that it looked considerably better if the featured products were first in the list. So, the following change makes special products jump up to the top of your list, with the rest of the product according to your standard ordering rules:

shop.browse.php – Line 450:
$q .= "\n ORDER BY product_special desc, $orderbyField $DescOrderBy";

If you want to see the final result, check out the SnugBaby Baby Carrier pages.

The post Featured Products With Virtuemart appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/featured-products-virtuemart/feed/ 7
Virtuemart Category Discounts https://www.leewillis.co.uk/virtuemart-category-discounts/ https://www.leewillis.co.uk/virtuemart-category-discounts/#comments Thu, 30 Apr 2009 08:30:23 +0000 http://www.leewillis.co.uk/?p=38 Background Virtuemart is an excellent Open Source e-Commerce system that integrates with the Joomla content management system. I use it on a number of sites – some with more challenging eCommerce requirements than others. While Virtuemart offers bulk purchase discounts … Continue reading

The post Virtuemart Category Discounts appeared first on Lee Willis.

]]>
Background

Virtuemart is an excellent Open Source e-Commerce system that integrates with the Joomla content management system. I use it on a number of sites – some with more challenging eCommerce requirements than others.

While Virtuemart offers bulk purchase discounts (£10 each, or 3 or £27 style offers) – it unfortunately only implements these on a per-product basis. This is great if you want to order 3 of the exact same pair of baby shoes.

However, a common request is to implement category-based discounts, so  for example you would be able to offer a discount where people buy multiple products from a particular category.

We do just this on SnugBaby, where we periodically run category based discounts on our baby shoes, where the requirement is that you get a discount if you choose to buy multiple products from a particular category.

Caveats

There are some caveats to the approach we’re going to describe below:

  1. It involves patching the Virtuemart source files  – this is not a Plugin, Component, or module. You should attempt this only if you’re comfortable editing PHP code
  2. Further to the above – if you upgrade Virtuemart this will need re-applying, possibly with some tweaks and tickles
  3. This assumes you’re running Virtuemart 1.1.3 (Although the theory of the approach works with VM 1.0.x as well)

Summary

This approach uses the Virtuemart bulk pricing model to store the bulk prices. This means you need to go through the products that are on special offer and add in the bulk prices. In the example I’m going to use here we are selling baby shoes. The standard price is £16.50 per pair, but if you buy more than 1 pair (Of any design), then you get them for £15.00 per pair.

We market this as “2 for £30” – however the reality (Probably should be caveat number 4!) is that it becomes £15 per pair for any number of shoes 2 and over (E.g. you could get 3 pairs for £45, 4 pairs for £60 and so on …).

So. First things first. Add the pricing to Virtuemart. If you’ve never done bulk pricing in Virtuemart here’s a quick guide. For each of your products in turn, edit the product, and choose “List Prices”:

listprices

Then you’ll need to specify your pricing:

productprices

Once this is done then your customers can get the special price, but only if they buy 2 or more of the same product.

The fun part

We can make all the changes we need to in just one file, administrator/components/com_virtuemart/classes/ps_product.php. This file is responsible for calculating product pricing, taking into account quantity discounts. The function in question is get_price().

This function out-of-the-box is given a product ID and is asked to calculate the price. It has a section relating to quantity pricing which roughly follows the following logic:

– Cycle through all cart contents

– If the product_id of the cart item matches the product_id we’re trying to cost then sum up the quantity of this item

– Retrieve the product price based on total volume of a product in the cart

We’re going to amend the second step such that it sums up the quantities of all products in the same category as the product we’re trying to cost.

The full patch (For the impatient) is here.

The patch is split into 2 main sections. The first gets the category that the product we’re costing belongs to (Caveat #5 – I have no idea what happens if your bulk purchase products are in multiple categories!). It also checks if that category is eligible for bulk discounts. You’ll need to change the 28 below to match your category ID.

Line 1608:
// Get the product_parent_id for this product/item
$product_parent_id = $this->get_field($product_id, “product_parent_id”);
// LW PATCH – Get the category of this product – used later to drive category-based multiple purchases
$sesq = “SELECT category_id FROM #__{vm}_product_category_xref WHERE product_id=’$product_id'”;
$db->setQuery($sesq); $db->query();
$db->next_record();
$sesprodcat = $db->f(“category_id”);
if ($sesprodcat == 28) {
$ses_cat_discount = TRUE;
} else {
$ses_cat_discount = FALSE;
}
// END LW PATCH

The next section changes the calculation so that instead of comparing the product IDs, we comapre category IDs:

Line 1622:
// LW PATCH – If any product in the cart is in the same category then treat as volume purchase
if ($ses_cat_discount) {
  $sesq = “SELECT category_id FROM #__{vm}_product_category_xref WHERE product_id='”.$cart[$i][“product_id”].”‘”;
  $db->setQuery($sesq); $db->query();
  $db->next_record();
  $sesprodchildcat = $db->f(“category_id”);
  if ($sesprodchildcat == $sesprodcat) {
    $quantity += $cart[$i][“quantity”];
  }
} else {

  if ($cart[$i][“product_id”] == $product_id) {
    if ($parent) {
      $parent_id = $cart[$i][“parent_id”];
Line 1631:
       }
     }
   }
}
// END LW PATCH

And that’s that. Give it a try, let me know what you think!

The post Virtuemart Category Discounts appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/virtuemart-category-discounts/feed/ 61