Do you run a Wordpress CMS with the WP-Shopping-Cart plugin? I was recently working on a project for a website running the Wordpress CMS with the WP-Shopping-Cart and I needed a way to have a different price for shipping depending on each specific quantity amount.
Shipping Price by Default
By default, the WP Shopping Cart plugin lets you setup a flat rate shipping amount for each product regardless of how many (quantity) are purchased. But this is a problem when you need to up the flat rate when more quantity is ordered. So here is a quick fix to that. Locate in your plugin directory the processing_functions.php file. Inside the nzshpcrt_determine_item_shipping function. I changed the function to the following:
function nzshpcrt_determine_item_shipping($product_id, $quantity, $country_code)
{
global $wpdb;
if(is_numeric($product_id) && (get_option(‘do_not_use_shipping’) != 1)) {
$sql = “SELECT * FROM".$wpdb->prefix."product_listWHEREid=’$product_id’ LIMIT 1″;
$product_list = $GLOBALS['wpdb']->get_row($sql,ARRAY_A) ;
if($product_list['no_shipping'] == 0) {
//if the item has shipping
if($country_code == get_option(‘base_country’)) {
$additional_shipping = $product_list['pnp'];
} else {
$additional_shipping = $product_list['international_pnp'];
}
if ($quantity >= 16)
{
$shipping = 0;
} elseif ($quantity < 16 && $quantity >= 11)
{
$shipping = 7;
} elseif ($quantity < 11 && $quantity >= 6)
{
$shipping = 6;
} elseif ($quantity < 6 && $quantity >= 2)
{
$shipping = 5;
} else
{
$shipping = 2;
}
// $shipping = $quantity * $additional_shipping;
} else {
//if the item does not have shipping
//$shipping = 0;
}
} else {
//if the item is invalid or all items do not have shipping
//$shipping = 0;
}
return $shipping;
}
You can see where the Quantity numbers and Shipping prices go in depending on your needs. This is a very helpful and useful piece of code. Of course, if you are using UPS or USPS for shipping quotes than there is no need for this. But for a custom flat rate shipping amount for different amounts of quantities this is a great way to do it. If you want to learn more about this Ecommerce shopping cart plugin for Wordpress you can read my article Ecommerce for your Wordpress Blog.
- Digg this post
- Bookmark this post on del.icio.us
- Stumble this post
- Mention on Facebook









Leave a comment