WP E-commerce plugin: Variation weight patch

Tags:

The wp-e-commerce plugin -- http://wordpress.org/extend/plugins/wp-e-commerce/ -- works very well but has the annoying property that if you define variations on a product, the Product Weight you set in the main configuration for that product is ignored and the weight taken from each variant... except that weight is on the "More" screen which by default is hidden next to the variation name and price!

This little patch corrects that annoyance by using the main product's weight, if the variant's weight is zero. NOTE if you really want a variant that makes the product weigh nothing, this patch is not for you!

<div id="_mcePaste">*** wp-content/plugins/wp-e-commerce/wpsc-includes/cart.class.php~      2010-11-17 08:36:55.000000000 -0700
--- wp-content/plugins/wp-e-commerce/wpsc-includes/cart.class.php       2010-11-17 09:26:53.000000000 -0700
***************
*** 1718,1724 ****
--- 1726,1738 ----
                        $priceandstock_values = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_VARIATION_PROPERTIES."`
WHERE `id` = '{$priceandstock_id}' LIMIT 1", ARRAY_A);                                                               

                        $price = $priceandstock_values['price'];
+
+                       // PATCH -- wl 2010-11-17
                        $weight = wpsc_convert_weights($priceandstock_values['weight'], $priceandstock_values['weight_unit']);
+                       if ($weight == 0) { // Use weight of main product without the variant.
+                         $weight = wpsc_convert_weights($product['weight'], $product['weight_unit']);
+                       }
+
                        $file_id = $priceandstock_values['file'];                                                    

                } else {</div>