jawuy 0 Newbie Poster

Hi all,

First of all thank you for taking the time to read my question:

i am trying to custom code an autocalculation on weight (not using the weight based module) in opencart v. 2.3.0.2. ihave checked for modules and there are non you may recommend weight based shipping or formula based shipping but they do not work the way i want them to. so here is the question:-

How do i calculate excess weight for example the first 20kgs fixed rate 300 + vat an extra kg is 30 + vat

so here is what im trying to do:

Untitled.png

And here is the code im going to use P.S. the variables are dummy until i find the real variables. I know im mixing up the old php coding method with object oriented php but i am not strong with oophp, so if you can help me convert this code to oophp i'd really appreciate.

1) where is the weight from the picture i attached coming from?
2) what are the variables used?
3) how do i add the weight calculation below the eco tax and add it to the total?

here is my code:-

if ($weight <= 20.50){
    echo "price is 300 + vat";
}elseif($weight > 20.50){
    for ($i>20; $i=30; $i++){
        echo "price is $i"
    }
}else{
    echo "no weight defined";
}

If the code doesnt make sense i kidnly request for help. Thank you very much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.