public function setShippingMethod() { $rates = \GC::getShippingMethodOptions(); $hash = \CI::input()->post('method'); foreach ($rates as $key => $rate) { $test = md5(json_encode(['key' => $key, 'rate' => $rate])); if ($hash == $test) { \GC::setShippingMethod($key, $rate, $hash); //save the cart \GC::saveCart(); echo json_encode(['success' => true]); return false; } } echo json_encode(['error' => lang('shipping_method_is_no_longer_valid')]); }