0

I'm trying to do an add to shooping cart button. But what happens now when I use the button is this: http://imgur.com/ldEEOK3

I want the button when I click on it, it adds the product to the cart, and stays in the same page.

<tr class="record"> <td><?php echo $row['ref']; ?></td> <td><?php echo $row['nome']; ?></td> <td><?php echo $row['preco']; ?></td> <td><form method="post" action="https://www.paypal.com/cgi-bin/webscr" target="paypal"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="paypalID"> //not gonna show it :p <input type="hidden" name="item_name_1" value="<?php echo $row['nome']; ?>"> <input type="hidden" name="quantity_1" value="1"> <input type="hidden" name="amount_1" value="<?php echo $row['preco']; ?>"> <input type="image" src="https://www.paypalobjects.com/pt_PT/PT/i/btn/btn_cart_SM.gif" border="0" name="submit" alt="PayPal - A forma mais fácil e segura de efetuar pagamentos online!"> <img alt="" border="0" src="https://www.paypalobjects.com/pt_PT/i/scr/pixel.gif" width="1" height="1"> </form> </tr> 

And I will post the code for the show cart button, but I guess it has no problems since it is working fine:

<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" > <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="encrypted" value="erased the big encrypt code"> <input type="image" src="https://www.paypalobjects.com/pt_PT/i/btn/btn_viewcart_SM.gif" border="0" name="submit" alt="PayPal - A forma mais fácil e segura de efetuar pagamentos online!"> <img alt="" border="0" src="https://www.paypalobjects.com/pt_PT/i/scr/pixel.gif" width="1" height="1"> </form>

2 Answers 2

1

You may want to change some of the variables in the Add-to-cart button:

<form method="post" action="https://www.paypal.com/cgi-bin/webscr" target="paypal"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="add" value="1"> <input type="hidden" name="business" value="paypalID"> //not gonna show it :p <input type="hidden" name="item_name" value="<?php echo $row['nome']; ?>"> <input type="hidden" name="quantity" value="1"> <input type="hidden" name="amount" value="<?php echo $row['preco']; ?>"> <input type="image" src="https://www.paypalobjects.com/pt_PT/PT/i/btn/btn_cart_SM.gif" border="0" name="submit" alt="PayPal - A forma mais fácil e segura de efetuar pagamentos online!"> <img alt="" border="0" src="https://www.paypalobjects.com/pt_PT/i/scr/pixel.gif" width="1" height="1"> </form> 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot. But another part of my question was also if I could click on the add to cart button, and don't be redirected to the shooping cart. Is it possible? @pp_pduan
There's no way you will stay on the page when you're working with cart buttons. You may consider an open source shopping cart system (e.g. Magento, OpenCart) to achieve that
1

The code you created is for "cart upload" function. It is usually used when some shopping cart feature has been embedded in your site and to pass the contents of shopping carts to PayPal for checkout and payment processing.

https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/cart_upload/

Please check below link for sample codes of "Add to cart" button.

https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/paypal_shopping_cart/#id08AEC030FDB

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.