Punit Gajjar
Punit Gajjar

Reputation: 4987

Weight based shipping , shipping charge per every 500grams

I would like to ask if there is an easy and flexible way to add stepped weight:price entries. For example there is an courier that charges as follows :

Up to 500 gram - Cost : HK$10

and from then and on for every additional 500 gram it costs HK$5 each.

First i would like to know if this kind of settings/logic is possible to implement in Opencart(2.0.1.1) and if it is possoble then What is the proper formula to enter such kind settings page of "Weight Based Shipping -> Rates" ?

Upvotes: 0

Views: 214

Answers (1)

user5139148
user5139148

Reputation:

Use following code it will work for you

    $weight = 100; // total weight of your shipment
    $findWeight = $weight/500; //total weight divided by your weight
    if($findWeight > 1){
        $charge = 10; //basic charge
        for($i=1; $i < $findWeight; $i++){
            $charge = $charge+5;
        }
    }
    else
    {
        $charge = 10;
    }
    echo "$".$charge; //total charges

Upvotes: 2

Related Questions