0

I am converting a Magento 1 site to Magento 2 and need to upgrade an Owebia Advanced Shipping configuration file. I'm ok with most of the file but need to help on what this line should be replaced with

"fees": "{cart.weight} > 30010 ? 262.56 + (ceil(({cart.weight} - 30010) / 1000) * 2.4) : {table {cart.weight} in 2510:50.40, 3010:55.20, 3510:61.20}"
0

I got a prompt reply when I contacted Owebia. Solution is:

'price' => $request->package_weight > 30010
            ? 262.56 + (ceil(($request->package_weight - 30010) / 1000) * 2.4)
            : array_reduce([ [2510, 50.40], [3010, 55.20], [3510, 61.20] ], function ($carry, $item) use ($request) {
                if (isset($carry)) return $carry;
                if (isset($item[0]) && ($request->package_weight <= $item[0] || $item[0] == '*')) {
                    $carry = $item[1];
                }
                return $carry;
            }),

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.