📁 PHP Dosya Yöneticisi
/
/
home
/
demodesigncom
/
matba.demodesign.com.tr
/
application
/
controllers
📝
Ajaxs.php
← Geri Dön
<?php /* Bu Dosya Tüm Ürünlerin Ajaxs Post İşlemlerini Yapıyor */ defined('BASEPATH') or exit('Bu Sayfaya Giriş İzniniz Bulunmamaktadır'); class Ajaxs extends CI_Controller { function __construct() { parent::__construct(); // Site Açıkmı Kontrolü $this->tema->site_durum(); // Tablo helper $this->load->helper('tablo_helper'); // Model Dosyası $this->load->model('Auth_model'); } public function varyantHesapla() { $varyant_post = $this->input->post('varyant_tipleri'); $urun = $this->db->select('varyant, varyant_fiyat, fiyat')->where("urun_id", $this->input->post('urun_id'))->get('urunler')->row(); // Varyant fiyat hesaplama $urun_fiyati = $urun->fiyat; $sabit_fiyat = 0; $artan_fiyat = 0; $varyant_listesi = json_decode($urun->varyant, true); foreach ($varyant_post as $key => $varyant_adi) { foreach ($varyant_listesi[$key]['alt_ozellik'] as $key => $varyant_ozellik) { if ($varyant_ozellik['adi'] == $varyant_adi) { if ($varyant_ozellik['maliyet'] == "artan"){ if ($varyant_ozellik['islem'] == '%') { $artan_fiyat += ($urun_fiyati / 100) * $varyant_ozellik['fiyat']; } if ($varyant_ozellik['islem'] == '+') { $artan_fiyat += $varyant_ozellik['fiyat']; } } if ($varyant_ozellik['maliyet'] == "sabit"){ if ($varyant_ozellik['islem'] == '%') { $sabit_fiyat += ($urun_fiyati / 100) * $varyant_ozellik['fiyat']; } if ($varyant_ozellik['islem'] == '+') { $sabit_fiyat += $varyant_ozellik['fiyat']; } } } } } // Varyant fiyat toplamları $urun_fiyati = $artan_fiyat + $urun_fiyati; // Adet fiyat hesaplama $return = []; $adet_listesi = json_decode($urun->varyant_fiyat, true); foreach ($adet_listesi as $key => $adet) { $return['fiyat_listesi'][$adet['adet']] = $urun_fiyati; if ($adet['islem'] == '%') { $return['fiyat_listesi'][$adet['adet']] = bcadd(0,($urun_fiyati / 100) * $adet['fiyat'] + $urun_fiyati + $sabit_fiyat); } if ($adet['islem'] == '+') { $return['fiyat_listesi'][$adet['adet']] = bcadd(0,$urun_fiyati + $adet['fiyat'] + $sabit_fiyat); } /** Seçilen adete göre sepet fiyatını değiştirir */ if ($this->input->post('adet') == $adet['adet']) { $sepet_fiyati = $return['fiyat_listesi'][$adet['adet']]; } } //Seçilen adet ve fiyatlar sepet fiyat ve adet olarak atanır $_SESSION['sepet_fiyat'] = $sepet_fiyati; $_SESSION['sepet_adet'] = $this->input->post('adet'); //Form'dan gelen adet miktarı geriye gönderilir $return['secilen_adet'] = $this->input->post('adet'); echo json_encode($return); } public function sepetEkle() { $return = []; //Gelen ID'ye göre ürün bilgileri getirilir $urun = $this->db->select('urun_id, urun_baslik, urun_resim') ->where("urun_id", $this->input->post('urun_id')) ->get('urunler') ->row(); $urunid = $urun->urun_id ; $urun_adi = $urun->urun_baslik; $resim = $urun->urun_resim; $adet = $_SESSION['sepet_adet'] ; $uye = $this->session->userdata('uyeid'); $fiyat = $_SESSION['sepet_fiyat']; @$birimfiyat = @$fiyat / $adet; unset($_SESSION['varyant'][$urunid]); $varyant_post = $this->input->post('varyant_ozellikleri'); foreach ($varyant_post as $key => $varyant_adi) { $sepet['varyant'][] = $varyant_adi; } $sepet_urunleri = array( 'sepet_uyeid' => $uye, 'sepet_urun' => $urun_adi, 'sepet_varyasyon' => $sepet['varyant'], 'sepet_birimfiyati' => @$birimfiyat, 'sepet_adet' => $adet, 'sepet_tarih' => date('d/m/Y'), 'sepet_toplami' => $fiyat, 'sepet_kdvoran' => 18, 'sepet_kdvtutar' => 0, 'urun_resim' => $resim, 'urun_id' => $urunid ); $sepet = array( 'id' => rand(), 'qty' => $adet, 'price' => @$birimfiyat, 'name' => $urun_adi, 'options' => $sepet_urunleri ); //$this->cart->destroy(); $sepet_ekle = $this->cart->insert($sepet); if ($sepet_ekle) { $return['type'] = 'success'; $return['sepet_urun_sayisi'] = count($this->cart->contents()); $return['message'] = 'Ürün Sepetinize Eklendi'; } else { $return['type'] = 'warning'; $return['message'] = 'Lütfen Daha Sonra Tekrar Deneyiniz'; } echo json_encode($return); } public function sepetWidget(){ $this->load->view('site/static/sepet_widget'); } }
💾 Kaydet
İptal
📝 Yeniden Adlandır
İptal
Kaydet
🔐 Dosya İzinleri (chmod)
İzin Değeri:
Hızlı Seçim:
777
755
644
600
777
= Herkes okur/yazar/çalıştırır
755
= Sahip tam, diğerleri okur/çalıştırır
644
= Sahip okur/yazar, diğerleri okur
600
= Sadece sahip okur/yazar
İptal
Uygula