Psytanium Posted May 10, 2017 Share Posted May 10, 2017 Recently our store started selling online fireplaces and its accessories, products are really heavy, starting from 50Kg to 500kg and maybe more. The shipping company DHL charges us 5$ for each 0.5Kg Using the zone rates, i have to write a string of incremental weight and price, starting from 0 to reach 500kg+, I have to write 1000 piece of mordor code for every geozone, e.g. 3:8.50,7:10.50,99:20.00 ............................... is there a way to write only something like : 5$ per 0.5Kg ? Link to comment Share on other sites More sharing options...
♥bruyndoncx Posted May 12, 2017 Share Posted May 12, 2017 should not be too difficult to change it do that you apply the rate (per kg) to the actual shopping cart weight upto a certain limit KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt Link to comment Share on other sites More sharing options...
♥bruyndoncx Posted May 12, 2017 Share Posted May 12, 2017 if you post the code, we ll indicate what to change ... KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt Link to comment Share on other sites More sharing options...
♥Moxamint Posted May 12, 2017 Share Posted May 12, 2017 Here is the conceptual code: $rate_table = preg_split("/[:,]/" , constant('MODULE_SHIPPING_ZONE_COST_' . $dest_zone)); $table_size = sizeof($rate_table); $tmp_weight = ceil($shipping_weight); for ($i=0; $i<$table_size-2 && $tmp_weight>0; $i+=2) { ##################################################### $shipping += min($tmp_weight, $rate_table[$i]) * $rate_table[$i+1]; # If zone shipping is 2:5.3,4:4.2,1:3.1 # $tmp_weight -= floatval($rate_table[$i]); # it means the first 2KG costs $5.3 per kilo # } # the next 4KG costs $4.2 per kilo # # the rest of weight costs $3.1 per kilo # if ($tmp_weight > 0) $shipping += $tmp_weight * $rate_table[$i+1]; ##################################################### So you simply double the total weight and the rate table would be as simple as 1:5 if you charge $5 for every 0.5 kilo. Link to comment Share on other sites More sharing options...
♥bruyndoncx Posted May 12, 2017 Share Posted May 12, 2017 @@Moxamint conceptually looking good to me , the proof is in the pudding or not ? @@Psytanium KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt Link to comment Share on other sites More sharing options...
Psytanium Posted May 17, 2017 Author Share Posted May 17, 2017 @@Moxamint thank you, its working as you said. but is there a way to make it work per 0.5 kg ? Link to comment Share on other sites More sharing options...
♥Moxamint Posted May 18, 2017 Share Posted May 18, 2017 @@Moxamint thank you, its working as you said. but is there a way to make it work per 0.5 kg ? @@Psytanium Double the weight. Cheers, Eddy Link to comment Share on other sites More sharing options...
♥Moxamint Posted May 18, 2017 Share Posted May 18, 2017 Line 3 => $tmp_weight = 2 * ceil($shipping_weight); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.