Zen Cart Logo
Forums / General Questions / Problem with my "buy now"

Problem with my "buy now"

Views: 2,686

Results 1 to 17 of 17
27 Apr 2012, 12:54 PM
#1
joecooper avatar

joecooper

Zen Follower

Join Date:
Aug 2011
Posts:
122
Plugin Contributions:
0

Problem with my "buy now"

Hi,

If you go to this page: http://www.purenappycakes.com/boys-baby-gifts-c-7.html and click "buy now" on the cup cakes. then from the shopping cart click "back to shopping", then click "buy now" for any other item. The cup cake quantity goes up 1, instead of adding other items to the cart.
I noticed the button for every product then links to the same item number.

Any ideas to what could be causing this?

Thanks

Joe

27 Apr 2012, 2:58 PM
#2
stevesh avatar

stevesh

Black Belt

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

Re: Problem with my "buy now"

It doesn't do it if the customer uses the Back browser button rather than Continue Shopping. What happens if you turn off your URL-rewriting mod and try again ?

17 May 2012, 1:33 PM
#3
joecooper avatar

joecooper

Zen Follower

Join Date:
Aug 2011
Posts:
122
Plugin Contributions:
0

Re: Problem with my "buy now"

sorry for the delayed response.

after disabling it. the problem goes away. So there must be a problem in the .htaccess file? or the zen cart addon?

17 May 2012, 1:44 PM
#4
joecooper avatar

joecooper

Zen Follower

Join Date:
Aug 2011
Posts:
122
Plugin Contributions:
0

Re: Problem with my "buy now"

After clicking the "buy now" link, the "continue shopping" button then contains the product_id of the last product added to the cart.

http://www.purenappycakes.com/boys-baby-shower-gifts-c-7.html?sort=1a&products_id=142

"&products_id=142". Is there anyway to stop this being added, as im guessing the re-write mod is using this.

15 Oct 2013, 6:48 PM
#5
raimond avatar

raimond

Zen Follower

Join Date:
Jul 2004
Location:
The Netherlands, Wierden
Posts:
423
Plugin Contributions:
0

Re: Problem with my "buy now"

did you solve this...i've got the same problem

15 Oct 2013, 7:16 PM
#6
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Problem with my "buy now"

joecooper:

After clicking the "buy now" link, the "continue shopping" button then contains the product_id of the last product added to the cart. ... "&products_id=142". Is there anyway to stop this being added, as im guessing the re-write mod is using this.
So just to clarify this for anyone else reading this post. This is not a problem specific to using a "re-write" mod

A clean install of Zen Cart with no plugins / modules installed will add "&products_id=142" to the end of the URL in the history when "Display Product Add to Cart Button = 2" and "Display Multiple Products Qty Box Status = 0". With these options enabled Zen Cart's default template adds the "&products_id=142" to the form as the "action".

So basically the user's template is adding the "&products_id=142" to the form action which is the cause of if appearing in the URL.

I have not tested against Zen Cart 1.3.x. In Zen Cart 1.5.x $_GET is not used by the routine to add a product to the shopping cart ($_POST is used instead) so clicking "continue shopping" does not add additional products. This was verified with a clean install of Zen Cart 1.5.0, a clean install of Zen Cart 1.5.1, and an install of Zen Cart 1.5.1 w/ one of the common plugins to generate alternative URLs.

So the question is: "If you are running Zen Cart 1.5.x, what is different in your installation (or settings) which causes $_GET to be used by the routine to add a product to the shopping cart"?

15 Oct 2013, 7:35 PM
#7
raimond avatar

raimond

Zen Follower

Join Date:
Jul 2004
Location:
The Netherlands, Wierden
Posts:
423
Plugin Contributions:
0

Re: Problem with my "buy now"

lhungil:

So just to clarify this for anyone else reading this post. This is not a problem specific to using a "re-write" mod

A clean install of Zen Cart with no plugins / modules installed will add "&products_id=142" to the end of the URL in the history when "Display Product Add to Cart Button = 2" and "Display Multiple Products Qty Box Status = 0". With these options enabled Zen Cart's default template adds the "&products_id=142" to the form as the "action".

So basically the user's template is adding the "&products_id=142" to the form action which is the cause of if appearing in the URL.

I have not tested against Zen Cart 1.3.x. In Zen Cart 1.5.x $_GET is not used by the routine to add a product to the shopping cart ($_POST is used instead) so clicking "continue shopping" does not add additional products. This was verified with a clean install of Zen Cart 1.5.0, a clean install of Zen Cart 1.5.1, and an install of Zen Cart 1.5.1 w/ one of the common plugins to generate alternative URLs.

So the question is: "If you are running Zen Cart 1.5.x, what is different in your installation (or settings) which causes $_GET to be used by the routine to add a product to the shopping cart"?

I just installed a clean ZenCart 1.5.1 with demo data...to get this same issue
Then I go to the backend Configuration - Product Listing and set Display Multiple Products Qty Box Status and Set Button Location to 0

then I go to the frontend and go to the category DVD Movies :: Action.......then i start to "click buy" - "continue shopping" and repeat that several times with of course different products in that categorie.
Then I install Ú-SEO URL, and do the same thing.

Wat happens: I click on Die Hard With A Vengeance Linked - Buy Now -- and Continue shopping
Then I click on Fire Down Below Linked - Buy Now

And **two times **Die Hard With A Vengeance Linked in my card

It makes no sense...sometimes after 2 clicks and sometimes after 10 clicks

15 Oct 2013, 9:02 PM
#8
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Problem with my "buy now"

raimond:

I just installed a clean ZenCart 1.5.1 with demo data...to get this same issue
Then I go to the backend Configuration - Product Listing and set Display Multiple Products Qty Box Status and Set Button Location to 0

then I go to the frontend and go to the category DVD Movies :: Action.......then i start to "click buy" - "continue shopping" and repeat that several times with of course different products in that categorie.
Then I install Ú-SEO URL, and do the same thing.

Wat happens: I click on Die Hard With A Vengeance Linked - Buy Now -- and Continue shopping
Then I click on Fire Down Below Linked - Buy Now

And **two times **Die Hard With A Vengeance Linked in my card

It makes no sense...sometimes after 2 clicks and sometimes after 10 clicks
You are right, it makes no sense. Doing this same test on both a clean Zen Cart 1.5.1 and a clean Zen Cart 1.5.1 w/ the latest version of "Ultimate URLs" does not exhibit this behavior.

Just to make sure it was not random I ran up and down the entire list of demo products under "DVD Movies" -> "Action" twice... Clicking "add to cart" product 1, "continue shopping", "add to cart" product 1, "continue shopping", "add to cart" product 3, etc. Still unable to duplicate this behavior in the above environments.

Are you downloading Zen Cart 1.5.1 manually from this site and running zc_install? What are you using up upload the files? Is there a proxy between you and the server? What browser are you using? What "add-ons" are installed in your browser? Have you tried clearing the cache, cookies, and saved form data?

When Zen Cart 1.5.1 encounters "?action=add_product&products_id=18" the "&products_id=18" is not used or read... The "action=add_product" triggers the shopping cart to add $_POST['products_id'] and does nothing with $_GET['products_id']... And the "continue shopping" link does not contain "action=" at all, so the code to add a cart is not called when clicking on "continue shopping".

15 Oct 2013, 9:20 PM
#9
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Problem with my "buy now"

As $_GET['products_id'] is not used by the "add_product" action in Zen Cart 1.5.1 you can modify the core Zen Cart code to stop adding the superfluous "&products_id=18" to the form (only happens with the settings you mentioned earlier in this thread).

I do not recommend modifying core Zen Cart files except as a last resort. Best practice is to avoid modifying core Zen Cart files whenever possible to avoid future upgrade entanglements and issues.

While this should NOT be needed... Open up "/includes/modules/product_listing.php". For Zen Cart 1.5.1 go to line 136 and remove "products_id" from the URL. When you are done it should look something like this:

} else {
// qty box with add to cart button
  if (PRODUCT_LIST_PRICE_BUY_NOW == '2' && $listing->fields['products_qty_box_status'] != 0) {
    $lc_button= zen_draw_form('cart_quantity', zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=add_product'), '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>';
  }
}

Note: The only way I can see this affecting anything is if you have other modifications made to your Zen Cart installation which attempt to use $_GET['products_id'] instead of $_POST['products_id']... Such as AJAX calls implemented by a 3rd party modification to Zen Cart... Or corrupted files...

16 Oct 2013, 7:43 AM
#10
raimond avatar

raimond

Zen Follower

Join Date:
Jul 2004
Location:
The Netherlands, Wierden
Posts:
423
Plugin Contributions:
0

Re: Problem with my "buy now"

lhungil:

You are right, it makes no sense. Doing this same test on both a clean Zen Cart 1.5.1 and a clean Zen Cart 1.5.1 w/ the latest version of "Ultimate URLs" does not exhibit this behavior. Just to make sure it was not random I ran up and down the entire list of demo products under "DVD Movies" -> "Action" twice... Clicking "add to cart" product 1, "continue shopping", "add to cart" product 1, "continue shopping", "add to cart" product 3, etc. Still unable to duplicate this behavior in the above environments.

Yes, it is random...when i do it again and again...different products will be stored in the shopping cart. Just random...
You did set the Configuration - Product Listing and set Display Multiple Products Qty Box Status and Set Button Location to 0

lhungil:

Are you downloading Zen Cart 1.5.1 manually from this site and running zc_install? What are you using up upload the files? Is there a proxy between you and the server? What browser are you using? What "add-ons" are installed in your browser? Have you tried clearing the cache, cookies, and saved form data?
Of course I downloaded the ZC151 from this site and run the zc_install. Downloaded and installed the latest version of "Ultimate URLs". No proxy. Tried local and on normal webhost. Chrome and Firefox tested, clean browser (clear cache and cookies)

lhungil:

I do not recommend modifying core Zen Cart files except as a last resort. Best practice is to avoid modifying core Zen Cart files whenever possible to avoid future upgrade entanglements and issues.

While this should NOT be needed... Open up "/includes/modules/product_listing.php". For Zen Cart 1.5.1 go to line 136 and remove "products_id" from the URL. When you are done it should look something like this:

Didn't work...same issue :(

16 Oct 2013, 3:46 PM
#11
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Problem with my "buy now"

raimond:

Yes, it is random...when i do it again and again... You did set the Configuration - Product Listing and set Display Multiple Products Qty Box Status and Set Button Location to 0[/B]
Yup, I did. My tests along with reading through the Zen Cart code is why it really does not make sense... I even tried guest vs. logged into an account (clean Zen Cart 1.5.x and clean Zen Cart 1.5.1 w/ USU)... Not saying you are not seeing the issue in your installation (you would not be here if you were not)... Just saying I have not yet been able to duplicate the behavior...

raimond:

...
Of course I downloaded the ZC151 from this site and run the zc_install. Downloaded and installed the latest version of "Ultimate URLs". No proxy. Tried local and on normal webhost. Chrome and Firefox tested, clean browser (clear cache and cookies) ...
Had to ask, sometimes the "automated" install scripts bork things. What is the OS of the local computer?

Link to the "test" site so we can see the generated HTML (and form fields - one per each "add to cart")? Any chance the form is being clicked upon before the browser finishes loading and rendering the HTML (such as on a slower server / connection)?

Can you check and make sure the browser is set to not "save" form data? ($_POST is populated from a form... Maybe something in the browser is repopulating the form data with old data? Try running the browser with all add-on's disabled?)

raimond:

...
Didn't work (removing "&products_id=" from the URL)...same issue :(
This means you are definitely going to want to check what data is being embedded in the forms (in particular the hidden products_id input field). The generated form + content comes from Zen Cart's core code unless a theme or module has been installed which overrides the code. The same is true for the code handling when "action=add_product" is one of the query parameters in a URL...

16 Oct 2013, 5:11 PM
#12
raimond avatar

raimond

Zen Follower

Join Date:
Jul 2004
Location:
The Netherlands, Wierden
Posts:
423
Plugin Contributions:
0

Re: Problem with my "buy now"

I have tried now also with (besides chrome and firefox) also with a clean safari and ie (no extensions installled, never use them), but same.

If you want I can install a clean zc151 demo and install later USEO...give you grant access to backend and ftp.

16 Oct 2013, 6:34 PM
#13
raimond avatar

raimond

Zen Follower

Join Date:
Jul 2004
Location:
The Netherlands, Wierden
Posts:
423
Plugin Contributions:
0

Re: Problem with my "buy now"

go to http://demo.boekenhandel.eu/, just installed (clean install with demo data, by zc_install...no errors, after that SEO installed, no errors)

DVD Movies - Action

And buy something, Continu shopping....buy someting different in that categorie....Continu shopping....buy someting different in that categorie....Continu shopping....buy someting different in that categorie....Continu shopping....buy someting different in that categorie....Continu shopping....buy someting different in that categorie....etc.

And it will go wrong (btw tested on windows 7 with almost all browsers)

16 Oct 2013, 7:00 PM
#14
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Problem with my "buy now"

Ahh, this is why providing full details is always so important. Note my earlier post. You have different settings then the ones I have been testing / talking about.

It appears you have:
Display Product Add to Cart Button: 1
Display Multiple Products Qty Box: 0

That said, I can see the problem. Looks like a bug is present in the Zen Cart code as "stock" Zen Cart is adding "http://site/index.php?main_page=index&cPath=3_10&sort=20a&products_id=12&action=buy_now&products_id=11" to the form action. Note the "double" inclusion of "products_id=". This can potentially cause issues depending upon how the web server handles the parameter being included twice.

Give me a few minutes and I'll work up a patch to the Zen Cart core code to fix the issue for you. And thank your patience!

16 Oct 2013, 7:25 PM
#15
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Problem with my "buy now"

I've tested the following changes in "stock" Zen Cart 1.5.1 and Zen Cart 1.5.1 w/ USU (various different settings). Seems to work in my environments to remove the extra "products_id" Zen Cart is currently generating... Could you please try making the following changes to "/includes/modules/product_listing.php" and let me know if it works for you.

Original Code (starting around line #127):

            // hide quantity box
            if ($listing->fields['products_qty_box_status'] == 0) {
              $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>';
            } else {
              $lc_button = TEXT_PRODUCT_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $listing->fields['products_id'] . "]\" value=\"0\" size=\"4\" />";
            }
          } else {
// qty box with add to cart button
            if (PRODUCT_LIST_PRICE_BUY_NOW == '2' && $listing->fields['products_qty_box_status'] != 0) {
              $lc_button= zen_draw_form('cart_quantity', zen_href_link($_GET['main_page'], 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>';
            }

Patched Code (changes in red):

            // hide quantity box
            if ($listing->fields['products_qty_box_status'] == 0) {
              $lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action', 'products_id')) . 'action=buy_now&products_id=' . $listing->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"') . '</a>';
            } else {
              $lc_button = TEXT_PRODUCT_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $listing->fields['products_id'] . "]\" value=\"0\" size=\"4\" />";
            }
          } else {
// qty box with add to cart button
            if (PRODUCT_LIST_PRICE_BUY_NOW == '2' && $listing->fields['products_qty_box_status'] != 0) {
              $lc_button= zen_draw_form('cart_quantity', zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action', 'products_id')) . 'action=add_product'), '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', 'products_id')) . 'action=buy_now&products_id=' . $listing->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"') . '</a>';
            }
17 Oct 2013, 7:56 AM
#16
raimond avatar

raimond

Zen Follower

Join Date:
Jul 2004
Location:
The Netherlands, Wierden
Posts:
423
Plugin Contributions:
0

Re: Problem with my "buy now"

lhungil:

I've tested the following changes in "stock" Zen Cart 1.5.1 and Zen Cart 1.5.1 w/ USU (various different settings). Seems to work in my environments to remove the extra "products_id" Zen Cart is currently generating... Could you please try making the following changes to "/includes/modules/product_listing.php" and let me know if it works for you.

GREAT :D, that works!

Okay core-modification, but most important that it works.

Thanks

is this a ZC bug or USEO bug?

17 Oct 2013, 5:31 PM
#17
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Problem with my "buy now"

I'd consider it a Zen Cart bug... For two main reasons:

  1. As the products_id from a previous action ends up being left in $_GET when the current action is occurring on a different products_id...

  2. In most Apache + PHP situations defining a query key more than once results in $_GET only containing the last one defined in the URL (farthest right). Some programming languages handle this differently, but the general rule is to never include a query key twice (one can always use an array if they intend to pass two values for one key).

Now in defense of the Zen Cart development team... Because the last key in the URL is the present in $_GET... This is not a bug which will show up easily when performing functionality testing... Especially since the form will act as expected...

"Ultimate URLs" does not expect to be passed duplicate query keys (see #2 above)... Internally some legacy code performs a "sort" of the query terms (key+value) when processing the request. The means the sort may change the order "duplicate" query terms are processed (and internally "Ultimate URLs" follows the same convention as PHP and only keeps the last encountered query key).

So in conclusion the cause of the erratic behavior is a combination of how "Ultimate URLs" handles query terms + the "bug" in Zen Cart.

IMHO the best long term solution would be to fix the Zen Cart code to not include the duplicate query key. This would avoid any possibility of a Web Server, PHP interpreter, or third party code possibly selecting the wrong query key+value combination to use when adding a product to the shopping cart. It also may not be a bad idea to look into using $_POST to pass the necessary data instead of $_GET.

When I get some time I'll probably take a look at the pre-release Zen Cart 1.6 code. If no one has already submitted a patch I'll contribute one for this file.