Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Why does movign the "Add to cart" button on product_info.php cause it not to work?


rs2k

Recommended Posts

Posted

I tried to move the "Add to cart" button from the bottom of the page to under the product image and now it won't work. When you click on it nothing happens. I've tried moving it to many different parts of the page without success.

 

 

Any idea why?

Posted

you arent moving the entire chunk of code then.. make sure you do ALL of the code for the button.. I did it successfully.

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Posted

Looks like your moving the add to cart button BEFORE your making the database call to find out which product is being viewed ... and hence you dont have the product id value yet to add it to the cart

Posted
you arent moving the entire chunk of code then.. make sure you do ALL of the code for the button.. I did it successfully.

 

 

Hmm, in desperation I moved about 20 lines around the code to the top of the page. It still did not work.

Posted

As a test I put 4 Buy Now buttons on this page. The HTML code for all four buttons look like this in page source:

<!--				<tr>

			  <td height="30"><a href="http://www.url.com/prod-name-p-82.html?action=buy_now"><img src="includes/languages/english/images/buttons/button_buy_now.gif" border="0" alt="Buy Now" title=" Buy Now " width="60" height="14"></a>
			</tr>
-->

 

 

Only the bottom one works.

Posted

why are your buttons hardcoded??

 

Are you using a template?

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Posted
why are your buttons hardcoded??

 

Are you using a template?

 

 

Here is the php code:

			  <tr>
			<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
		  </tr>

 

I'm not using a template.

Posted

You have likely moved the button out of the actual form tags...

 

Can you post the whole source of the page, not just the button code?

 

Thanks,

 

Rob

Rob Bell - Inspired Graphix

Customising osCommerce in Australia, and the world!

View my profile for web and email links.

 

I'm sorry, but i cannot offer Free support via PM etc, and osCommerce forums prohibit me from putting any reference to paid support in my signauture.

However viewing my profile may provide links to my website or something like that which you may find useful.

Posted
You have likely moved the button out of the actual form tags...

 

Can you post the whole source of the page, not just the button code?

 

Thanks,

 

Rob

 

That was the problem.

 

While moving some things around I got the form tag moved as well.

 

 

Thank you!

Posted
That was the problem.

 

While moving some things around I got the form tag moved as well.

 

 

Thank you!

 

Gotta be careful in there :D

An easy mistake to make...

;)

 

Rob

Rob Bell - Inspired Graphix

Customising osCommerce in Australia, and the world!

View my profile for web and email links.

 

I'm sorry, but i cannot offer Free support via PM etc, and osCommerce forums prohibit me from putting any reference to paid support in my signauture.

However viewing my profile may provide links to my website or something like that which you may find useful.

Posted

your add to cart should look like this:

				<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>

 

Your button just has a link, but no statements to tell the cart which product to pull form the DB to put into the cart.. That is NOT the stock cart button... Either you coded it yourself, got it from a bad contribution, or something else../

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Posted
your add to cart should look like this:

				<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>

 

Your button just has a link, but no statements to tell the cart which product to pull form the DB to put into the cart.. That is NOT the stock cart button... Either you coded it yourself, got it from a bad contribution, or something else../

 

 

The OP has already said this is resolved - the only problem was that he moved the submit button out of the form tags.

 

Why is everyone trying to overcomplicate this?

 

Rob

Rob Bell - Inspired Graphix

Customising osCommerce in Australia, and the world!

View my profile for web and email links.

 

I'm sorry, but i cannot offer Free support via PM etc, and osCommerce forums prohibit me from putting any reference to paid support in my signauture.

However viewing my profile may provide links to my website or something like that which you may find useful.

Posted

i am trying to point out the proper way to code your add to cart button to avoid future issues.. hardcoding links is not a good idea in ecommerce

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Posted
i am trying to point out the proper way to code your add to cart button to avoid future issues.. hardcoding links is not a good idea in ecommerce

 

 

The OP post their code, and it is correct - it is not being hardcoded...

They post a snippet from "view source" which may have caused some confusion.

 

Reading the posts in this thread would have shown that, including the OP's post of the functions being used.

 

Anyway, all that aside, the issue is resolved.

 

Rob

Rob Bell - Inspired Graphix

Customising osCommerce in Australia, and the world!

View my profile for web and email links.

 

I'm sorry, but i cannot offer Free support via PM etc, and osCommerce forums prohibit me from putting any reference to paid support in my signauture.

However viewing my profile may provide links to my website or something like that which you may find useful.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...