php - How to add multiple add to cart buttons on one form -


i have 16 products, of have separate add cart buttons assigned them. when customer enters desired quantity , clicks add cart, product added shopping cart , customer directed corresponding paypal shopping cart. wondering if there way carry out same action without having make individual buttons each product?

this code 1 of buttons:

<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="hosted_button_id" value="93xbl9hz8d5mg">                         <table>                         <tr><td><input type="hidden" name="add" value="1"></td></tr><tr><td>                         <input type="hidden" name="item_name" value="ar.vin.001 - unframed">                         qty <input type="text" name="quantity" maxlength="5" value="1" style="position: relative; width:30px; height: 23px; top: 25px; left: 35px;">                              </table>                         <input type="image" src="./img/button.gif" border="0" name="submit" alt="paypal – safer, easier way pay online."  style="position:relative; left: 50px; top: 0px;">                         <img alt="" border="0" src="https://www.paypalobjects.com/en_gb/i/scr/pixel.gif" width="1" height="1">                     </form>' 

your title , question seem have different meanings, answer title query ( how add multiple add cart buttons on 1 form ).

the simple answer don't. can simulate doing this, , can think of 2 ways of doing this, 1 javascript, other php.

php way:

make add cart buttons link index.php?action=add&product_id=4, , don't show paypal form on page. in corresponding page, generate paypal redirect form depending on product id, , whatever info want send, submit javascript. ideally, should make timer, , add message like: "you redirected paypal in 5 secs. if not, click link below".

javascript way:

have paypal form exist on page, hidden. then, add onclick action on add cart buttons, changes paypal form input values depending on button clicked, submit javascript.


personally, prefer php way because have more control. example, can save order before redirecting paypal, depends on needs. javascript way more of hack solution.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -