Success,
Here is a work around solution that will allow you to offer a flat rate shipping charge for the first item plus a fixed cost for each additional item. This solution allows you to create different pricing rules for individual carriers. Different pricing rules by shipping method. Different pricing rules for specific locations. It can used to create simple flat rate policies. And it can be used to offer free shipping to specific locations.
Say you wanted to charge the following shipping fees:
UPS Ground $5.95 1st item + $2.00 ea. add'l item (USA only)
UPS Flate Rate $14.95 (International only)
USPS Priority Mail $5.00 1st item + $1.20 ea. add'l item (USA + International)
USPS Book Rate $3.50 1st item + $ .75 ea. add'l item (USA + International)
Free Shipping to customers in your city
Summary:
This solution uses VM's Standard Shipping Module. You only need to add "one" additional line of code to standard_shipping.php then use the standard VM "Shipping / Create a Shipping Rate" to create multiple "flat rate + additional cost" or multiple flat rate shipping policies or multiple location based free shipping.
Edit the file:
/your_site_root/administrator/components/com_virtuemart/classes/shipping/standard_shipping.php
Locate the following section:
$total_shipping_handling = $dbr->f( "shipping_rate_value" ) + $dbr->f( "shipping_rate_package_fee" ) ;
$total_shipping_handling = $GLOBALS['CURRENCY']->convert( $total_shipping_handling ) ;
$total_shipping_handling *= $taxrate ;
$show_shipping_handling = $CURRENCY_DISPLAY->getFullValue( $total_shipping_handling ) ;
Add/Insert the following line indicated in red:
$total_shipping_handling = $dbr->f( "shipping_rate_value" ) + $dbr->f( "shipping_rate_package_fee" ) ;
$total_shipping_handling = $GLOBALS['CURRENCY']->convert( $total_shipping_handling ) ;
$total_shipping_handling *= $taxrate ;
$total_shipping_handling = $d["zone_qty"] * $dbr->f( "shipping_rate_value" ) + $dbr->f( "shipping_rate_package_fee" ) ;
$show_shipping_handling = $CURRENCY_DISPLAY->getFullValue( $total_shipping_handling ) ;
How this new line of code works:
This work around solution uses the number of items in the shopping cart as the "cost for each additional item" and adds a fixed base amount. The fixed base amount is added to the total to create the "cost for the first item".
So if you wanted to charge $5.95 for the 1st item + $2.00 ea. add'l item. the math is ((quantity of items in cart * 2.00) + $3.95)
Say you only have one item in the cart, the math is: ((1*2.00)+3.95)= $5.95, or, the cost for your first item.
Now lets say that you have three items in your cart, the math is: ((3*2.00)+3.95)= $9.95, or, $5.95 for the 1st item plus $2.00 ea. for the 2 additional items.
If you wanted to charge a flat rate of $14.95, the math is ((quantity of items in cart * 0) + $14.95)
If you wanted to offer free shipping for a location, the math is ((quantity of items in cart * 0) + 0)
If you wanted to charge $5.00 for the 1st item + $ 1.20 ea. add'l item. the math is ((quantity of items in cart * 1.20) + $3.80)
If you wanted to charge $3.50 for the 1st item + $ .75 ea. add'l item. the math is ((quantity of items in cart * 0.75) + $2.75)
How you configure it in VM:
1) Enable Standard Shipping under "Admin / Configuration / Shipping" make sure that the Standard Shipping Module is checked.
2) Create a shipping rate under "Shipping / Create a Shipping Rate"
This work around solution changes the definition or purpose of the fields "Fee:" and "Your package fee:". "Fee:" is now the multiplier to "items in cart" and "Your package fee:" is now the added fixed base amount.
The above formula is now: ((items in cart * Fee:) + Your package fee:)
As in the above examples, if you wanted to charge $5.95 for the 1st item + $2.00 ea. add'l item. Enter the following:
Fee: 2.00
Your package fee: 3.95
If you wanted to charge a single Flat Rate fee of $14.95, enter:
Fee: 0.00
Your package fee: 14.95
- This works because "items in cart" * 0 = 0, then the "Your package fee:" is added. Providing you with a fixed amount flat rate.
As in the above examples, if you wanted to charge $5.00 for the 1st item + $1.20 ea. add'l item. Enter the following:
Fee: 1.20
Your package fee: 3.80
If you wanted to offer free shipping to a specific zone, zip, city, state or country. Specify the zip code range of a zone, city, or state. To specify a country, select it from the country list. Then enter the following:
Fee: 0.00
Your package fee: 0.00
You can create multiple combinations of the above shipping rates with this solution. Just give each shipping rate the appropriate "Shipping rate description:". e.g. UPS Ground or USPS Priority Mail. Then select the appropriate zip code range and/or country(s) that the shipping rate applies to.
This solution also works with the automatic order confirmation email. The order confirmations will display the ship method that you entered into the rule's "Shipping rate description:".
I haven't needed it yet but I believe that it would be fairly easy to offer free shipping over a specific dollar amount (i.e. $50.00) by using the following logic:
if cart total > 50.00
$total_shipping_handling = 0 ;
else
$total_shipping_handling = $d["zone_qty"] * $dbr->f( "shipping_rate_value" ) + $dbr->f( "shipping_rate_package_fee" ) ;
If you want flat rate shipping only and do not need an additional cost per item. Then enter the following code:
$total_shipping_handling = $dbr->f( "shipping_rate_value" ) + $dbr->f( "shipping_rate_package_fee" ) ;
In this scenario, use the "Fee:" field to enter the amount of your flat rate. This scenario also allows you to use the "Your package fee:" as normal.
Drawbacks to this approach are:
- It breaks the Standard Shipping module. Because it changes the meaning or function of the fields "Fee:" and "Your package fee:" all rules created using Standard Shipping module will be calculated in this way.
- During version upgrades it will be lost when the PHP file is replaced and therefore it will need to be manually coded again.
Note: I am a consultant and I am posting this solution to hopefully generate some business. I can be contacted at dbochenek@compitsol.com for services or consultation.
I hope that this solution is of some use to you.
David