You are here:  » Buy now button on product page


Buy now button on product page

Submitted by Julian on Sat, 2006-09-09 10:32 in

what code do i need to add to use a buy now button on the product page ?

Thanks

Submitted by support on Sat, 2006-09-09 11:34

Hi Julian,

If you study html/product.php you will see the following code that generates the "Buy Now" link for the product name:

<h3><a href='<?php print tapestry_buyURL($mainProduct); ?>' <?php print javascript_statusBar(translate("go to")." ".$mainProduct["merchant"]); ?>><?php print $mainProduct["name"]; ?></a></h3>

The actual URL itself is returned by tapestry_buyURL($mainProduct); so you can use this if you want to create a button, for example:

  <form method='GET' action='<?php print tapestry_buyURL($mainProduct); ?>'>
    <input type='submit' value='Buy Now' />
  </form>

If that doesn't work - it is most likely because $mainProduct is out of scope - but anywhere after line 3 in html/product.php should be fine.

Cheers,
David.

Submitted by Julian on Sat, 2006-09-09 12:00

thanks

how do i make it a grapic button ?

Submitted by support on Sat, 2006-09-09 12:25

Hi Julian,

I think it's just this...

  <form method='GET' action='<?php print tapestry_buyURL($mainProduct); ?>'>
    <input type='image' src='/path/to/image.gif' />
  </form>

Note that i've used an absolutely path to the image - that is important so that it can be found whatever page of your site the button appears on.

Cheers,
David.

Submitted by Julian on Sat, 2006-09-09 12:45

i Get this error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /includes/database.php on line 21

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /includes/database.php on line 26

Warning: Cannot modify header information - headers already sent by (output started at /includes/database.php:21) in /jump.php on line 14

Submitted by support on Sat, 2006-09-09 19:15

Hi Julian,

Did it work as a normal button? Was it only when you made the changes to be a graphic button that you got these errors?

Cheers,
David.

Submitted by Julian on Sat, 2006-09-09 19:22

Hi David

both button scripts dont work - i still have the "merchants name" as a link on the page that does work

Thanks

Submitted by support on Sun, 2006-09-10 09:30

Hi Julian,

Sorry about that - it's because the URL to jump.php requires the ?id on the end, and when the form is using the GET method the browser strips it off so jump.php does not know what product ID to skip to!

It works fine using the POST method, so use this instead:

  <form method='POST' action='<?php print tapestry_buyURL($mainProduct); ?>'>
    <input type='image' src='/path/to/image.gif' />
  </form>

Cheers,
David.

Submitted by Julian on Sun, 2006-09-10 11:01

Thanks - Works fine now