MOD: Flat Shipping plus $x.xx per additional item
Posted: Sat Jul 24, 2010 4:25 am
My apologies if someone already posted something like this, but I wanted to share a modification I made that allows you to charge a flat shipping rate for the first item and then $x.xx extra for each additional item. This is a modified version of my $1 shipping per additional item post, which dealt with specifically adding $1 per extra item. This solution allows you to specify something other than $1 for subsequent items:
1. Ensure Flat Rate Shipping is Enabled in 'Extensions > Shipping > Flat Rate' and you have the desired rate entered for shipping one item.
2. Next, open 'catalog > model > shipping > flat.php'
FIND:
REPLACE WITH:
(Change 2.00 to whatever amount you want to charge for each additional item shipped)
FIND:
REPLACE WITH:
FIND:
REPLACE WITH:
What this does:
It will take your flat shipping rate and add a flat 2.00 dollar amount for each additional item in the cart. You can enter your own amount by changing 2.00 in the code above to whatever you want. Just make sure the value does not contain a dollar sign or any other symbol aside from the decimal. As always, be sure to make a backup of files before modifying them.
1. Ensure Flat Rate Shipping is Enabled in 'Extensions > Shipping > Flat Rate' and you have the desired rate entered for shipping one item.
2. Next, open 'catalog > model > shipping > flat.php'
FIND:
Code: Select all
$quote_data = array();
(Change 2.00 to whatever amount you want to charge for each additional item shipped)
Code: Select all
$quote_data = array();
if($this->cart->countProducts() > 1)
{
$custom_count = 2.00 * ($this->cart->countProducts() - 1);
}
else
{
$custom_count = 0;
}
Code: Select all
'cost' => $this->config->get('flat_cost'),
Code: Select all
'cost' => $this->config->get('flat_cost') + $custom_count,
Code: Select all
'text' => $this->currency->format($this->tax->calculate($this->config->get('flat_cost'), $this->config->get('flat_tax_class_id'), $this->config->get('config_tax')))
Code: Select all
'text' => $this->currency->format($this->tax->calculate($this->config->get('flat_cost') + $custom_count, $this->config->get('flat_tax_class_id'), $this->config->get('config_tax')))
It will take your flat shipping rate and add a flat 2.00 dollar amount for each additional item in the cart. You can enter your own amount by changing 2.00 in the code above to whatever you want. Just make sure the value does not contain a dollar sign or any other symbol aside from the decimal. As always, be sure to make a backup of files before modifying them.