Cart in CodeIgniter Reviewed by Momizat on . controller.php [php] $this->cart->destroy(); public function updatecart($id) { $allpro=$this->cart->contents(); if(!empty($allpro)){ foreach($allpro controller.php [php] $this->cart->destroy(); public function updatecart($id) { $allpro=$this->cart->contents(); if(!empty($allpro)){ foreach($allpro Rating: 0

Cart in CodeIgniter

controller.php


$this->cart->destroy();

public function updatecart($id)
	{
		$allpro=$this->cart->contents();
		if(!empty($allpro)){
			foreach($allpro as $allprovl){
				$data = array(
				   'rowid' => $allprovl['rowid'],
				   'qty'   => $this->input->post($allprovl['rowid'])
				);
				$this->cart->update($data);
			}
		}
		
		redirect($_SERVER['HTTP_REFERER']);
		exit;
	}
	public function removecart($id)
	{
		$data = array(
               'rowid' => $id,
               'qty'   => 0
            );
		$this->cart->update($data);
		redirect($_SERVER['HTTP_REFERER']);
		exit;
	}
	public function insertcart($id)
	{
		$rest=$this->User_model->get_product($id);
		
		$data = array(
               'id'      => $rest['id_tyres_details'],
               'qty'     => 1,
               'price'   => $rest['price_tyres_details'],
               'name'    => $rest['cat_name'],
               'options' => array('Tire_width' =>$rest['value_Tire_width'],
								'Aspect_ratio' => $rest['value_Aspect_ratio'],
								'Rim_diameter' => $rest['value_Rim_diameter'],
								'stocks_tyres' => $rest['total_stocks_tyres_details'],
								'cat_image'=> $rest['cat_image']
								)
				
            );
		$this->cart->insert($data);
		redirect($_SERVER['HTTP_REFERER']);
		exit;
	}

view.php

<?php	
	$this->cart->total_items();
?>
<form method="post" action="<?php echo base_url('welcome/updatecart/1');?>">
          <table class="table-striped table-condensed cf">
            <thead class="cf">
              <tr>
                <th>No.</th>
                <th>Item(s) Description</th>
                <th class="numeric">Qty.</th>
                <th class="numeric">Price</th>
                <th class="numeric">Total</th>
                <th class="numeric">Option</th>
              </tr>
            </thead>
            <tbody>
			<?php 
			$i=0;
			foreach ($this->cart->contents() as $items){ 
			$i++;
			?>
              <tr>
                <td data-title="NO"><?php echo $i;//echo "<pre>";print_r($items);?></td>
                <td data-title="Item"><div class="cart-product-image"> 
				<img src="<?php echo SITEURL.'tyresimg/'.$items['options']['cat_image'];?>"></div>
                  <div class="cart-product-discrp">
                    <p> <?php echo $items['options']['Tire_width'];?>/<?php echo $items['options']['Aspect_ratio'];?><?php echo $items['options']['Rim_diameter'];?> ( <?php echo $items['name'];?> )</p>
                  </div></td>
                <td data-title="Qty." class="numeric" >
				<input min="1" step="1" type="number" class=" text-center" value="<?php echo $items['qty'];?>" name="<?php echo $items['rowid'];?>">
				<?php if($items['options']['stocks_tyres']<$items['qty']){?>
				<br />
				<span style="color:red;">Not in stock!</span>
				<?php }?>
				</td>
                <td data-title="Price" class="numeric">$ <?php echo $items['price'];?></td>
                <td data-title="Total" class="numeric">$ <?php echo $items['subtotal'];?></td>
                <td data-title="Option" class="numeric"><button type="submit" class="btn btn-info btn-sm"><i class="fa fa-refresh"></i></button>
                  <a class="btn btn-danger btn-sm" href="<?php echo base_url('welcome/removecart/'.$items['rowid']);?>" onclick="return confirm('Do you want to remove?');"><i class="fa fa-trash-o"></i><?php //echo $items['rowid'];?></a></td>
              </tr>
			  <?php }?>
              <tr>
                <td class="total-price" colspan="4">Total Order Price: <i class="i fa fa-hand-o-right"></i></td>
                <td  class="total-cost"colspan="2">$<?php echo $this->cart->total();?></td>
              </tr>
              <tr>
                <td  style="padding:10px; text-align:left;" colspan="6"><span class="continue-shopping"> <a href="<?php echo base_url('tyres');?>">Continue Shopping</a> </span> <span class="check-out"> <a href="<?php echo base_url('welcome/checkout');?>">Checkout</a> </span></td>
              </tr>
            </tbody>
          </table>
		  </form>

Comments (69)

  • Kristi

    I’m truly enjoying the design and layout oof your website.
    It’s a very easy on the eyes which makes it much more
    pleasant for me to coome here and visit more often. Did you hire out a
    designer to create your theme? Superb work!

    Reply
  • Antoinette

    Hiya very nice blog!! Guy .. Beautiful ..Amazing ..
    I will bookmark your website and take the feeds also?
    I am happy to search out a lot of helpful info here within the submit, we need work out more
    techniques on thios regard, thank you ffor sharing. . . .

    . .

    Reply
  • Justina

    Every weekend i used to go to see this web site, because i want enjoyment, since this this site conations genuiinely niice funny information too.

    Reply
  • Winnie

    Excellent article. I certainly appreciate his website. Continue
    the good work!

    Reply
  • Chauncey

    Does your blog hage a contact page? I’m having
    problems locating it but, I’d likee to send you an email.
    I’ve got some recommendations for your blog you might bee
    interested in hearing. Either way, great site annd I look forwrd to
    seeing it develop over time.

    Reply
  • Keisha

    Hi there! Quifk question that’s completerly off topic.
    Do you know how to make your site mobile friendly?
    My blog looks weird when browsing from my apple iphone. I’m trying to find a template or
    plugin that migtht bbe able tto correct this issue.
    If you have any suggestions, please share. Cheers!

    Reply
  • Louella

    Yourr style is verdy unique compared too other
    people I’ve read stuff from. Thankks for posting when you’ve got the opportunity, Guess I will just book mark this
    page.

    Reply
  • Sergio

    Wonderful blog! I found it while surfing aroud on Yahoo News.
    Do you have any sugestions on how to get listed in Yaho News?

    I’ve been trying for a while but I never seem to get there!
    Cheers

    Reply
  • Aisha

    My developer is trying to persuade me to move to .net
    from PHP. I have always disliked the idea becauuse of the expenses.
    Buut he’s tryiong none the less. I’ve been using WordPress on several
    websites for about a year and am anxious about switching
    to anolther platform. I have heard good things about blogengine.net.

    Is therde a wway I can import all my wordpress posts into it?

    Any help would be greatly appreciated!

    Reply
  • Deangelo

    Aw, this wass a really nice post. Finding the tiime and actual effort to make a great article… but what caan I say… I put things off a
    whole lot aand don’t manage to get anything done.

    Reply
  • Chana

    Heya i am for the first time here. I cane across this
    boarfd and I find It truly useful & it helped me out a lot.
    I hope to give someyhing back and help others like you aided me.

    Reply
  • asad

    wheres the model?

    Reply
  • Elane

    Neat blog! Is youur theme custom made or did you download it from somewhere?
    A design like yours with a few simple twees wouldd really make my blog shine.
    Please let me know where you got your design. Bless
    you

    Reply
  • Geraldine

    My brother reecommended I might like this blog.
    He was totally right. This post actually made mmy day.

    You cann’t imagine just how much time I had spent for this information!
    Thanks!

    Reply
  • cheap cialis

    Saved as a favorite, I really like your web site!

    Here is my web-site … cheap cialis

    Reply
  • Carmine

    Great goods from you, man. I’ve understand your stuff previious to and you’re just
    too excellent. I really like what youu have acquired here,
    really like what you’re saying and the way in which you say it.
    You make it entertaining and you still care for to keep itt wise.

    I can’t wait to read far more from you. This is actually a great website.

    Reply
  • Abraham

    I appreciate, result in I discoverred exactly what I was taking a look for.
    You have ended my 4 day long hunt! God Bless you man.
    Have a great day. Bye

    Reply
  • Melody

    What a material of un-ambiguity and preserveness off valuable
    knowledge on the topic of unpredicted feelings.

    Reply
  • Juliann

    Yes! Finally something about to know more.

    Reply
  • Oliva

    Howdy are using WordPress for your site platform? I’m new to the blog world but I’m trying
    too get started and create my own. Do you need any html coding knowledge to make your own blog?
    Any help would be greatly appreciated!

    Reply
  • Leigh

    Excellent blog here! Also your web site loads up very fast!
    What host are you using? Can I geet your affiliate lunk to
    your host? I wish my website loaded up ass quickly as yours lol

    Reply
  • Shella

    It is in point of fact a great and herlpful piece off information. I’m glad that you shared
    this useful info with us. Please keep us up to date like this.
    Thanks for sharing.

    Reply
  • cialis

    Heya i’m for the primary time here. I found this board and I find It really
    useful & it helped me out much. I’m hoping to offer one thing back and aid others such
    as you helped me.

    Here is my web site … cialis

    Reply
  • Elva

    Hi, i read your blog occasionally and i own a
    similar one and i was just wondering iff you get a lot of spam feedback?
    If so how do you prevent it, any plugin or
    anything you can suggest? I get so much lately it’s driing
    me insane so any help is very much appreciated.

    Reply
  • goo.gl

    Thank you for the auspicious writeup. It actually usedd to be a entertainment account
    it. Glance complex too ffar delivered agreeable from you!
    However, how can we be iin contact?

    Reply
  • Christopher

    Caan I just say what a relief to uncover an individual who really understands what they’re discussing over the internet.
    You certainly know how to bring a problem to light and
    make it important. More people have to read this and understand
    this side off the story. I can’t believe you are not more popular since youu most certawinly have the gift.

    Reply
  • Billy

    Your style is unique compareed to other peple I have read stuff from.
    I appreciate you for posting when you have the opportunity, Gueas
    I’ll just bookmark this site.

    Reply
  • Sven

    My spouse and I stumbled over here coming from a different page and thought I may as wesll check things out.
    I like what I see so now i am followng you.
    Look forward to looking into your web page for a second time.

    Reply
  • Lowell

    Unquestionably believe that which you stated. Your favorite reason appeared
    to be on the web the easiest thing to be aware of.
    I say to you, I definitely get irked while people think about worries that they painly don’t know about.
    You managed to hit the nail upon tthe top as well ass dedfined
    out thhe whole thing without having side-effects , people could take a signal.
    Will likely be back to get more. Thanks

    Reply
  • Lela

    Hello, I want to subscribe for thiks weblog to take newest updates,
    so where can i do it pleae help.

    Reply
  • Phillis

    Wow that was odd. I just wrote an really long
    comment but after I clicked submit my commnent didn’t
    appear. Grrrr… well I’m not writing all that over again. Anyway, just wanted to say
    excellent blog!

    Reply
  • Tandy

    I do not even knpw how I ended up here, buut I thought thiss post was good.
    I don’t know who you are but certainmly you’re
    going to a famous blogger if you are not already ;) Cheers!

    Reply
  • Tandy

    Thanks for finally writkng about > Cart in CodeIgniter |
    PHP Short Notes < Loved it!

    Reply
  • Chloe

    You should take part in a contest for one of the greatest blogs on the net.

    I will highly recommend this website!

    Reply
  • Breanna

    As the admin oof this web page is working, no uncertainty very soon itt will
    be renowned, due to its quality contents.

    Reply
  • Selene

    Hi, i think that i saw you visited my weblog so i cam to
    “return the favor”.I’mtrying to find things to improve my site!I suppose iits ok tto use a few of your ideas!!

    Reply
  • https://goo.gl

    Nice blog here! Also your website loads up very fast!

    Whaat host are you using? Can I get your affiliate link to your
    host? I wish my site loaded up as fast aas yours lol

    Reply
  • Laurie

    I am really impressed witrh your writing skills and also with the layout
    on your weblog. Is this a paid theme or did you modify it yourself?
    Either way keep up the nice quality writing, itt iss rare to see
    a nie blog like this one today.

    Reply
  • https://goo.gl

    Wow, incredible blog layout! How long hhave you been blogging for?
    you make blogging look easy. The overalkl look oof your
    web site is fantastic, as well as the content!

    Reply
  • Hamish

    My brother suggested I might like this website. He wwas entirely right.
    This post truly made my day. You can not imagine just how mmuch
    time I had spent for tnis information! Thanks!

    Reply
  • Bell

    Greetings! Very elpful advice in this particular post!
    It is tthe little changes that produce the most important changes.
    Thanks a lot for sharing!

    Reply
  • Franziska

    This paragralh is really a pleasant one it helps new the web users, who are wishing for blogging.

    Reply
  • Poppy

    Hi there, all thhe time i used to check blog posts here in the
    eaely hours in the dawn, because i like to learn more and more.

    Reply
  • Stefanie

    you are truly a good webmaster. Thee website loading pace is amazing.
    It kind of feels that you’re doijg any unique trick.

    Also, The contents arre masterwork. you’ve performed a excellent activity in this matter!

    Reply
  • Tod

    Pretty! This has been an extremely wonderful post.

    Many thanks for providing tyese details.

    Reply
  • Eloise

    I go to see each day some web sites and websites
    to read posts, but this blog offers quality based articles.

    Reply
  • Merissa

    I waas curious if you ever considered changing the pagfe layout of your blog?
    Its very well written; I love what youve goot to say. But maybe you coluld a little more in the way of content so peolle could connect with it better.
    Youve ggot an aaful lot of text for only having one or 2 pictures.
    Maybe you cojld space it out better?

    Reply
  • Aracelis

    Hello! I realize this is somewhat off-topic however I needed
    to ask. Does running a well-established website like yours take a massive ampunt work?
    I’m brand new to writing a blog but I do write in my journal every
    day. I’d like to start a blog so I can share my experience and views online.

    Please leet me kknow if yoou hqve any kind of ideas or tips for
    brand new aspiring blog owners. Thankyou!

    Reply
  • Karri

    Have you ver thought about adding a little bbit more than just your articles?

    I mean, what you say is valuable and all. Buut imagine if you added some great pictures or video clips to give your posts
    more, “pop”! Your content is excellent but with pics and videeo clips, this
    site could undeniably be one of the best in iits field.

    Very good blog!

    Reply
  • Eugenia

    Hello there! This is kind of off topic but I need some advice
    from an established blog. Is it tough to set up your own blog?
    I’m not very techincal but I can fiigure things out pretty quick.

    I’m thinking about setting up mmy own but I’m not sure where to begin. Do you
    hve any tips or suggestions? Thank you

    Reply
  • Rosemarie

    Fantastic beat ! I would like to apprentice at the same time as you amend your site, how could i subscribe for a weblog website?
    The account aided me a acceptable deal. I were a littke bit acquainted
    of this your broadcast provided brilliant clear idea

    Reply
  • Hwa

    Great blog! Is your theme custom made or did you download it from somewhere?
    A design liike yours with a feww simple tweeks would really
    mwke my blog jump out. Please let me know where yoou got your theme.
    Thanks

    Reply
  • Jasmine

    Appreciate thhe recommendation. Let me try it out.

    Reply
  • Francis

    I don’t even know how I ended up here, but I thought this post was great.
    I don’t know whho you are butt certainly you are going to a
    famous blogger if you aree not already ;) Cheers!

    Reply
  • Stella

    I’m impressed, I have to admit. Seldom do I come across a blog
    that’s equally educative and engaging, and without
    a doubt, you hhave hit the nail on the head.
    The problem is something that too few folks are
    speaking intelligently about. I’m very happy that I ffound this
    in my search for something regarding this.

    Reply
  • Winona

    Hi there it’s me, I am also visiting this websie daily,
    this web page is actually fastidious and the viewers are actually
    sharing goid thoughts.

    Reply
  • Eva

    Hello, everything is going sound here and ofcourse every
    one is sharing facts, that’s actually excellent, kee up writing.

    Reply
  • Shani

    I’m extremely pleased to find this web site. I wanted
    to thank you for ones time just for this fantastic read!!

    I definitrly liked efery little biit of it and I have
    yyou saved as a favorite to see new stuff in your website.

    Reply
  • Nate

    magnificewnt issues altogether, you simply gained a brand nnew
    reader. What may you recommend in regards to your submit that you
    just made a few days ago? Any certain?

    Reply
  • Gabriela

    Iblog quite often and I truly appreciate your information. Your article
    has really peaked myy interest. I’m going to bookmark your blog and keep checking for new details aboput once per week.
    I subscribed to your Feeed aas well.

    Reply
  • Troy

    I’m curious to find out what blog platform you have bee utilizing?
    I’m experiencing some small security ssues with myy latest blog and I would like to find something more risk-free.
    Do you have any recommendations?

    Reply
  • Sophia

    For the reason that the admin of this website is working, no hesitation very shortly it wilpl be
    famous, duue tto its quality contents.

    Reply
  • https://www.pinterest.com/lighthousestora/

    I know this if off topic but I’m looking into starting my
    own blog annd was wondering what all is neded to get set
    up? I’m assuming having a blog like yours would cost a pretty penny?
    I’m noot very internet smart so I’m not 100% positive.
    Any suggestions or advice would be greatly appreciated. Thank you

    Reply
  • Christina

    Howdy! I could have swokrn I’ve been to this site before but after checking through some of the post I
    realized it’s new to me. Nonetheless, I’m definitely happy I found it annd I’ll be
    book-marking and checking back often!

    Reply
  • Manuel

    If you wiush for tto take a good deal from this article then you have too
    apply such strategies to your wwon webpage.

    Reply
  • Liliana

    Attrctive component of content. I just stumbled upon your website and in accession capital
    to claim that I gget in fact loved account your weblog posts.
    Any way I will be subscribing inn your feeds and even I fulfillment you access persistently rapidly.

    Reply
  • Eleanor

    Very quickly this website will be famous amid all blog people,
    due to it’s pleasant articles or reviews

    Reply
  • Lawrence

    An outstanding share! I have jut forwarded this onto a
    friend who has been conducting a little research on this.
    And hee in fact ordered me lunch due to the
    fact that I found iit forr him… lol. So allow me to
    reword this…. Thank YOU for the meal!! But yeah, thanhks for spending
    the time to talk about this issue here on your blog.

    Reply
  • Brain

    You’re so cool! I do not think I’ve trulyy read something like that before.
    So nice to discover someone with a few genuine thoughts on this subject.

    Really.. many thanks foor starting this up. This web site is one thing that is needed on the web, someone with
    a litrle originality!

    Reply

Leave a Comment

© 2014 Powered By