Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
First of all, hello to all of you! ;)

So. I'm trying to do something, and I would like to know if its possible with couch CMS or if you know any other way around it.

Ok, basically what I I want to do is an "order cart", and I would like to know if its possible to handle the products as clonnable pages. For example, I would like to make each cloned page a product and in each one of them I get an add to cart button. And I can navigate through all of them adding different products in different quantities. In the end I would like to have a "cart page" where I can see a table with each product added and the quantity of each one of them. In this page I would have a submit button to be able to send the data of this table to an email account... Is this possible in couch? or do I need to add my own php (which I don't control at all lol). Can somebody help me or point me to an easy solution.

Thank you very much in advance
Hi Chris,

Couch doesn't have a cart feature in-built so we'll have to look for third party tools to do the job.

Building even a relatively simpler e-commerce solution will, more often than not, run into complexities like - product variations, custom shipping rates, taxes, custom discounts etc.
As such it is always preferable to go with dedicated solutions like Magento etc.

If however your case is really simple -i.e. fixed prices for products, no or fixed shipping rates etc., you can take a look at JCart (http://conceptlogic.com/jcart/).
It is a very simple shopping cart and, as far as I could see, should be a no-brainer to integrate with Couch.
Just as you said, each product will have its own cloned page with editable regions for price etc.
A regular cms:pages loop will populate the products display and JCart can handle the rest.

Do let me know if you decide to take this route and happen to require any assistance with it.

Thanks
hi KK,

I've followed your advice and went for the Jcart way. However after almost finishing everything, I'm caught in a conflict between Jcart and couch. I hope you can help me out and find a solution since i've made such a big effort to put all this up.

Ok, so basically.

I was able to integrate the whole jcart system in my couch site. meaning that I'm able to handle each cloned page as a single product, and also I've categorised my products or cloned pages using couch folders system . This is great because I can add products to the shopping cart in both the page view and folder view. But the problem I'm having is that I have a place in the navigation bar of the site where the number of items in the shopping cart are shown. However as soon as i get to a folder view this info disappears completely and it appears as soon as I add an item from the list-view to the shopping cart.
I believe this is a conflict with the embed tag. Meaning that as soon as the folder view is called somehow the jcart .php files or .js on the list file are not being executed or perhaps since the embedded file is opened from the snippet folder, at the time of loading the file is unable to find the files because of a "wrong path from the snippets folder". The issue only ocurrs while the folder view is initially loaded.

I've tried many things with no succes.

If there's any suggestions I'll be grateful.

If you need the code files, please let me know and I'll send them to you.

Once again thank you!
Hey Chris,
I'll be only too glad to help.
If you have the site publicly accessible, send in your FTP + Couch creds.
If not, PM me a bundle of all the files and I'll definitely try to find what the problem is.
Hi,

I used the files you send on my setup and this is what the problem was -
Your 'item.php' uses <cms:embed "item_list.html" /> to handle the list-view.
The embedded 'item_list.html' above calls PHP at two places -
Code: Select all
   Line 14: <?php $jcart->display_cart();?>
   Line 51: value="<?php echo $_SESSION['jcartToken'];?>"

The problem here is that we cannot invoke PHP directly (i.e. using <?php .. ?> statements from within an embedded file.

To rectify the situation, we need to change the <?php .. ?> PHP statements to <cms:php> .. </cms:php> Couch statements..
The modified statements then become -
Code: Select all
   Line 14: <cms:php> global $jcart; $jcart->display_cart();</cms:php>
   Line 51: value="<cms:php> echo $_SESSION['jcartToken'];</cms:php>"

Please note that the $jcart variable had to be defined as a global because its is no longer being referred from the global scope of PHP.

The two change described above should have been sufficient but a little problem cropped up within the display_cart function (jcart.php line: 457).
The function uses an inner function (i.e. function defined within another function) tab -
Code: Select all
    
   public function display_cart() {
      ...   
          function tab($n) {
            $tabs = null;
            while ($n > 0) {
               $tabs .= "\t";
               --$n;
            }
            return $tabs;
         }
      ...
   }

Our main file 'item.php' also invokes <?php $jcart->display_cart();?> and then so does the 'item_list.html' that is embedded within it. This causes the tab function to be defined twice - which is an error situation.
The solution was to simply check if the function has not already been defined before actually defining it. So the modified code within jcart.php line: 457 now becomes -
Code: Select all
      if( !function_exists('tab') ){
         function tab($n) {
            $tabs = null;
            while ($n > 0) {
               $tabs .= "\t";
               --$n;
            }
            return $tabs;
         }
      }

And that is it.

Please make the amendments I listed above and let me know if everything works ok.
5 posts Page 1 of 1