Jump to content

Buy Button on Category Page


Guest

Recommended Posts

Hello guys

I followed freshyseth's instructions, and when a buy button that belongs to a product which does not have options was clicked from the viewCat page, the browser was indeed redirected to the same category page. However, I need it to do the same for products which do have options.

I hired someone to do some work on the store, and the product options are now displayed on viewCat. I'm trying to work out how to get the buy button to directly add the product, with chosen options, to the cart.

Here's what I've done:

Changed the viewCat.tpl buy_btn section from:

			<p><form action="{CURRENT_URL}" method="post" name="prod{PRODUCT_ID}">

				<!-- BEGIN: buy_btn -->

					<input type="hidden" name="add" value="{PRODUCT_ID}" />

					<div style="position: relative; text-align: right;">{LANG_QUAN} 

					<input name="quan" type="text" value="1" size="2" class="textbox" style="text-align:center;" />

					<a href="java script:submitDoc('prod{PRODUCT_ID}');" target="_self" class="txtButton">{BTN_BUY}</a></div>

				<!-- END: buy_btn -->

			</form></p>




to:




			<p><form action="{CURRENT_URL}" method="post" name="addtobasket">

				<!-- BEGIN: buy_btn -->

					<input type="hidden" name="add" value="{PRODUCT_ID}" />

					<input type="hidden" name="location" value="act=viewCat&catId={CAT_ID}&page={PAGE_NUM}" />

					<input type="text" name="quan" value="1" size="1" />

					<a href="java script:submitDoc('addtobasket');" class="txtButton">{BTN_BUY}</a>

				<!-- END: buy_btn -->

			</form></p>




This results in the following javascript error:




findObj(formName).submit is not a function

http://www.thegraphicedge.me.uk/js/jslibrary.js

Line 41

:unsure:

If anyone can help me add what I need to the viewCat page to get the direct add to work I'd appreciate it. Thanks.

Link to comment
Share on other sites

  • 2 months later...
  • 2 months later...
  • 2 weeks later...
Guest cornholio27

Have been trying Convict's code, which seems to work great by keeping the user on the cat page.

However, If you go into the viewprod page then try and go back via the browser button you now get the message warning about the page containing 'POST' data. So, if you click OK to go back the product is added again to the cart.

Any suggestions how to get round this?

thanks in advance

Link to comment
Share on other sites

MarksCarts mod suits me fine too. :mellow: Thank you very much.

One little thing missing. It jumps back to the first page in the category. Did anyone figure out how to get it to jump back to the same page. (i.e., If the customer clicks Buy on an item on page 4 of 5 it should jump back to that page and not the first page. The pages are zero indexed so page 4 will have page=3 in the URL.) The answer may be related to PAGINATION in viewCat.inc.php.

Link to comment
Share on other sites

  • 9 months later...
Guest alexjones

If anyone can help me, I installed the mod but i get the session problem. The buy button works only sometimes.

Can you tell me how can I fix this?

Thank you,

Alex

Link to comment
Share on other sites

  • 9 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...