Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / How to stop "add to cart" going to product infor page?

How to stop "add to cart" going to product infor page?

Locked
This thread is locked. New replies are disabled.
30 May 2010, 12:46 PM
#1
wilorc avatar

wilorc

New Zenner

Join Date:
Sep 2009
Posts:
65
Plugin Contributions:
0

Post #1 by wilorc

Hi

Zen Cart Version: 1.3.9c

I'm building a new Zen Cart. My question is about the "Add to Cart" button in the Product Listing page.

When someone clicks "Add to Cart" in the Product Listing page, I want to stop the page changing to the Product Info page and just stay on the Product Listing page. The reason for this is that I don't want the customer to have to keep clicking their back button to get back to the product listing page. Many of my customers know the products and don't need to see the product info page; they just want to add items to their cart and checkout. Is there an Admin setting for this, or would it require php coding changes?

I have gone through the options in Admin -> Configuration many times and couldn't see anything. I have also just spent the last three hours searching the forum, but still can't find anything.

Thank you.

30 May 2010, 3:28 PM
#2
robwuk avatar

robwuk

Zen Follower

Join Date:
Aug 2005
Location:
United Kingdom
Posts:
458
Plugin Contributions:
0

Post #2 by robwuk

I have mine set to display cart after adding product (admin/ my store / Display Cart After Adding Product set to true, this allows my users to click continue shopping after they see the contents of the basket and takes them back to where they were

if that helps

Rob

30 May 2010, 3:32 PM
#3
wilorc avatar

wilorc

New Zenner

Join Date:
Sep 2009
Posts:
65
Plugin Contributions:
0

Post #3 by wilorc

Thanks Rob. Sadly, that doesn't help. I am aware of that setting, but it causes the same problem; users have to keep clicking to go back to the previous page (which they never wanted to leave).

Are there any Zen experts who can advise whether this would have to be a coding change, i.e., to modify the URI so that it calls main_page=index instead of main_page=products_info?? Which file would need editing to achieve this??

Thanks.

30 May 2010, 6:18 PM
#4
wilorc avatar

wilorc

New Zenner

Join Date:
Sep 2009
Posts:
65
Plugin Contributions:
0

Post #4 by wilorc

I have figured out that it isincludes/modules/product_listing.php that is used. I have modified it as follows at line 141:

            if (PRODUCT_LIST_PRICE_BUY_NOW == '2' && $listing->fields['products_qty_box_status'] != 0) {
             // $lc_button= zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($listing->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $listing->fields['products_id']), 'post', 'enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($listing->fields['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_draw_hidden_field('products_id', $listing->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</form>';

                $string = zen_href_link(zen_get_info_page($listing->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $listing->fields['products_id']);
                $pattern = '/product_info/';
                $replacement = 'index';
                $lc_button= zen_draw_form_prod_list('cart_quantity', preg_replace($pattern, $replacement, $string), 'post', 'enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($listing->fields['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_draw_hidden_field('products_id', $listing->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</form>';

When an item is added to cart by an individual "Add to Cart" button, it stays on the products_listing page, instead of changing to the products_info page. This is only a "work around", but I've tested (including a full purchase of multiple items and checkout), and it appears to be working correctly.

If any of the Zen programers can anything wrong with doing this, I'd be very interested to know.

Thank you.

31 May 2010, 3:31 AM
#5
customgiftsshoppe avatar

customgiftsshoppe

New Zenner

Join Date:
May 2010
Posts:
16
Plugin Contributions:
0

Post #5 by customgiftsshoppe

works like a charm.
Thank you.:clap:

Custom Gift Shoppe
Mistik Games
Teach a man to fish and he'll eat for the rest of his life.

31 May 2010, 7:59 AM
#6
wilorc avatar

wilorc

New Zenner

Join Date:
Sep 2009
Posts:
65
Plugin Contributions:
0

Post #6 by wilorc

Here is the modified "zen_draw_form function that I am using in the above code. It basically AUTOCOMPLETE to be OFF in the quantity boxes:

/*
 * Modified form drawing function for product_listing page
 */
  function zen_draw_form_prod_list($name, $action, $method = 'post', $parameters = '') {
    $form = '<form AUTOCOMPLETE = "off" name="' . zen_output_string($name) . '" action="' . zen_output_string($action) . '" method="' . zen_output_string($method) . '"';

    if (zen_not_null($parameters)) $form .= ' ' . $parameters;

    $form .= '>';

    return $form;
  }
31 Jul 2010, 4:32 PM
#7
magiana avatar

magiana

New Zenner

Join Date:
Jul 2010
Posts:
11
Plugin Contributions:
0

Post #7 by magiana

wilorc:

I have figured out that it isincludes/modules/product_listing.php that is used. I have modified it as follows at line 141:

        if (PRODUCT_LIST_PRICE_BUY_NOW == '2' && $listing->fields['products_qty_box_status'] != 0) {
         // $lc_button= zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($listing->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $listing->fields['products_id']), 'post', 'enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($listing->fields['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_draw_hidden_field('products_id', $listing->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</form>';

            $string = zen_href_link(zen_get_info_page($listing->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $listing->fields['products_id']);
            $pattern = '/product_info/';
            $replacement = 'index';
            $lc_button= zen_draw_form_prod_list('cart_quantity', preg_replace($pattern, $replacement, $string), 'post', 'enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($listing->fields['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_draw_hidden_field('products_id', $listing->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</form>';
> 
> When an item is added to cart by an individual "Add to Cart" button, it stays on the products_listing page, instead of changing to the products_info page.  This is only a "work around", but I've tested (including a full purchase of multiple items and checkout), and it appears to be working correctly.  
> 
> If any of the Zen programers can anything wrong with doing this, I'd be very interested to know.
> 
> Thank you.

Which lines should I replace with the code above? 

First I tried to replace this at line 139:

if (PRODUCT_LIST_PRICE_BUY_NOW == '2' && $listing->fields['products_qty_box_status'] != 0) {
$lc_button= zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($listing->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $listing->fields['products_id']), 'post', 'enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($listing->fields['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_draw_hidden_field('products_id', $listing->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</form>';


Then this:

       if (PRODUCT_LIST_PRICE_BUY_NOW == '2' && $listing->fields['products_qty_box_status'] != 0) {
          $lc_button= zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($listing->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $listing->fields['products_id']), 'post', 'enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($listing->fields['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_draw_hidden_field('products_id', $listing->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</form>';
        } else {
          $lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"') . '</a>';

I have even tried to replace more code but in every case my product listing disappear.
31 Jul 2010, 4:42 PM
#8
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Post #8 by stevesh

Don't worry about line numbers - that seems to vary depending on your editor.

Here's what I did:

Copy the code from the thread above to the clipboard and paste it into Notepad (that's just so you can more easily see what you have).

Open the product_listing.php file and look around line 139 for the block of text that begins with **if (PRODUCT_LIST_PRICE_BUY_NOW ** and ends with BUTTON_IN_CART_ALT) . '</form>';

Highlight that section in the file, and Paste the new code to replace it in the file.

Save the file and upload it to the proper override folder.

You need to do this with a text editor, not something like Dreamweaver.

31 Jul 2010, 7:01 PM
#9
magiana avatar

magiana

New Zenner

Join Date:
Jul 2010
Posts:
11
Plugin Contributions:
0

Post #9 by magiana

Stevesh, you´re amazing! You are everywhere with a helping hand. Do you never sleep?

Unfortunately, I think it´s time to give up. I did the right thing from the beginning, except the override stuff. So I read the docs and tried to figure out where the override folder should be. The original file was in includes/modules/product_listing.php so I created an override folder here: includes/modules/override/product_listing.php. (I could not find any classic folder above that, but there is one in the modules folder.) It still doesn´t work.

I have also read that there should be a debugging tool in admin (v1.3.9) but the only thing I´ve found is TEXT_INFO_PURGE_DEBUG_LOG_FILES in store manager. I´ve clicked that but it doesn´t show anything.

I have used Notepad++ to edit the file and filemanager in cPanel to upload the file (not my FTP). The unedited file always shows up in mint condition, but the edited file...:(

1 Aug 2010, 12:18 PM
#10
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Post #10 by stevesh

includes/modules/overrides is correct if your custom template is named 'overrides'. Should work, though.

20 Aug 2010, 10:09 AM
#11
clueless_in_berlin avatar

clueless_in_berlin

New Zenner

Join Date:
May 2008
Posts:
48
Plugin Contributions:
0

Post #11 by clueless_in_berlin

wilorc:

Here is the modified "zen_draw_form function that I am using in the above code. It basically AUTOCOMPLETE to be OFF in the quantity boxes:

/*

  • Modified form drawing function for product_listing page
    */
    function zen_draw_form_prod_list($name, $action, $method = 'post', $parameters = '') {
    $form = '<form AUTOCOMPLETE = "off" name="' . zen_output_string($name) . '" action="' . zen_output_string($action) . '" method="' . zen_output_string($method) . '"';

    if (zen_not_null($parameters)) $form .= ' ' . $parameters;

    $form .= '>';

    return $form;
    }


I don´t undersand what you mean by this last entry.:cry:

I am using 1.3.8.  I tried to add the code that you originally wrote in this tread but when I upload the file, all my listings just vanish.  I am not getting it.  Do you think there is something that I am missing?