简体   繁体   中英

How to let a user select quantity on website as opposed to on the shopping cart

I have a drop down list on my website that contains the quantity available for a specific product however, when the user adds the product to the cart only 1 is displayed as opposed to 3 for example. Is there anyway i can get this to work?

This is the code for the dropdownlist/add to cart button:

<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="LVDZ4V9LJ7QQW">
                            <table>
                            <tr><td><input type="hidden" name="on0" value="Qty">Qty</td></tr><tr><td><select name="os0">
                                <option value="1">1 </option>
                                <option value="2">2 </option>
                                <option value="3">3 </option>
                                <option value="4">4 </option>
                                <option value="5">5 </option>
                                <option value="6">6 </option>
                                </select> </td></tr>
                                </table>
                            <input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
                            <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
                        </form>

I managed to figure it out. I changed and added the following and it seems to work 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="hosted_button_id" value="LVDZ4V9LJ7QQW">
                        <table>
                        <tr><td><input type="hidden" name="add" value="1">Qty</td></tr><tr><td>
                        <select name="quantity">
                            <option value="1">1 </option>
                            <option value="2">2 </option>
                            <option value="3">3 </option>
                            <option value="4">4 </option>
                            <option value="5">5 </option>
                            <option value="6">6 </option>
                            </select> </td></tr>
                            </table>
                        <input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
                        <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
                    </form>'

You can create a text box or drop down to allow the buyer to select the quantity. Then you would just populate the value into the variable "quantity" and pass it over with the rest of your variables. You dont need to pass it over using the variable "on0".

You could do this using the upload cart cmd, that would let the user select an amount.

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
        <input type="hidden" name="item_name_1" value="item name" />
        <input type="hidden" name="business" value="businessemail" />
        <input type="hidden" name="upload" value="1">
        <input type="hidden" name="item_number" value="Item Name">
        <select name="quantity_1"> 
            <?php for($x = 1; $x < 11; $x++){
                echo '<option value="'.$x.'">'.$x.'</option>';
            }?>
        </select>
        <input type="hidden" name="cmd" value="_cart">
        <input type="hidden" name="amount_1" value="10.00" />
        <input type="hidden" name="custom" value="" />
        <input type="hidden" name="weight" value="1" />
        <input type="hidden" name="weight_unit" value="kg" />
        <input type="hidden" name="shipping_1" value="1" />
        <input type="hidden" name="currency_code" value="GBP" />
        <input type="hidden" name="shopping_url" value="main_shop_url" />
        <input type="hidden" name="return" value="success_url" />
        <input type="hidden" name="cancel" value="cancel_url" />
        <input type="submit" value="Order Now" />
    </form>

This can be used for multiple items, for example you would append _x to each item_name_, quantity_, amount_ as you need. Full documentation can be found here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM