Kami Posted July 23, 2020 Report Share Posted July 23, 2020 Вопрос такой. Добавил расчет доставки по 2 городам через аякс, function showRaschet() { var raschet=$('form').serialize(); $.ajax({ type: 'POST', url: 'ajax/raschet.php', data: raschet, success: function(data){ if(result.found) { $('.raschet_price').html(data.success); $('.raschet_price').attr('data-cost', data.success); $('input[name="raschet_price"]').val(data.success); } } }); }; Расчет работает как нужно, в .raschet_price возвращается значение расчета, далее создал скрытый инпут куда добавляю значение расчета чтоб потом передать его <input name="raschet_price" disabled type="hidden" value=""/> Дальше в CartView.php добавил // Стоимость доставки $delivery = $this->delivery->get_delivery($order->delivery_id); if(!empty($delivery) && $delivery->free_from > $order->total_price) { /*raschet*/ $delivery->price = (floatval($this->request->post('raschet_price')) > 0 ? floatval($this->request->post('raschet_price')) : $delivery->price); /*/raschet*/ $this->orders->update_order($order->id, array('delivery_price'=>$delivery->price, 'separate_delivery'=>$delivery->separate_payment)); } Но по итогу все равно передается в $delivery->price , стоимость доставки указанная в настройках. Quote Link to post Share on other sites
Kami Posted July 23, 2020 Author Report Share Posted July 23, 2020 (edited) Странно, если убираю проверку и напрямую в переменную записываю то приходит /*$delivery->price = (floatval($this->request->post('raschet_price')) > 0 ? floatval($this->request->post('raschet_price')) : $delivery->price);*/ $delivery->price = floatval($this->request->post('raschet_price')); Edited July 23, 2020 by Kami Quote Link to post Share on other sites
shooroop Posted July 23, 2020 Report Share Posted July 23, 2020 if else используйте Quote Link to post Share on other sites
Kami Posted July 23, 2020 Author Report Share Posted July 23, 2020 if else используйте разобрался, не в if else проблема Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.