# Shipping the same for certain quantity

I would like to make it so that a certain quantity of a product has the same exact shipping price and when the quantity goes over the threshold, the shipping price doubles.

For example, for product X, the shipping price is Y for quantities 1-12. For 13-24, the shipping price is Yx2, for 25-36, it's Yx3 and so on.

The reason for this is the manufacturer considers anything in a box of 12 (whether it actually has 12 or not in there) is a certain "weight" (the weight is how much it would be if it was 12 products, even if there is less than 12 products in there).

To make thing a little more difficult, the shipping is not a flat rate throughout the website. Each product has a different weight and needs to be calculated differently from one another.

I hope this makes sense. It's very hard to explain over text. I'm new to Magento so I have no idea how to start looking for a solution.

Create your own shipping method following this tutorial.
in the `collectRates` of your module you need to put the logic for calculating the shipping price.

You can access the items in the shopping cart like this:

``````\$request->getAllItems();
``````

where `\$request` is the parameter you receive for the `collectRates` method.

You can do something like this (untested):

``````\$price = 0;
foreach (\$request->getAllItems() as \$item) {
//exclude duplicate items from the configurable products
if (\$item->getParentItemId()) {
continue;
}
\$qty = \$item->getQty();
\$factor = (int)((\$qty - 1) / 12) + 1; //this should give you the correct number of boxes but please check again
\$productShippingPrice = include logic here to determine the shipping price for one product or one box.
//add shipping price to total
\$price += \$productShippingPrice * \$factor;

}
//add the price to the shipping method. See who `\$method` is in the tutorial
\$method->setPrice(\$price);
``````
• Hi Marius, thanks for pointing me in the right direction! I'll take a look at this tutorial. – Tara Nov 12 '14 at 14:58