Using Checkboxes With The Plug and Play Purchase Parameters

While the Plug and Play parameter set is typically implemented based on the provided HTML code, it can be extended and used in other forms. In this article we will explain how you can use the plug and play parameters with checkboxes. This will allow you to build an order form on your site where your customers can check the products or services they wish to buy all at once. We will also look at the use of checkboxes for product add-on and options.

Checkboxes are typically used when you want to allow a visitor of your site to select one or more options from a set of alternatives. In an HTML form the checkbox input type carries the following common attributes.

  • Name – This attribute carries the name of the parameter that will be submitted with the form if the check box is checked. In our case this will carry the product_id parameter name.
  • Value – This attribute holds the value of the name attribute and is the value of the parameter that is passed with the form when the checkbox is checked. In our case this will carry the assigned product ID of the product that is associated with the check box.

To define a checkbox in our form we will create the input type and add the 2 attributes. This would look like the following example:

<input type='checkbox' name='product_id' value='1' />

When checked, this checkbox will pass the parameter named product_id with a value of 1 to the URL attached to the HTML form.

Now that we understand the basic attributes of the checkbox input type, and how to define one in our form, we will create a simple example. This example will allow the customer to purchase 1 of any product when they check the checkbox. Remember to subscript your product_id and quantity parameters with a corresponding digit. This will allow the customer to select multiple products at one time along with a quantity that corresponds to the product_id with the same subscript.

<form action='https://www.2checkout.com/checkout/purchase' method='post'>
<input type='hidden' name='sid' value='123' >
Product 1:
<input type='hidden' name='quantity1' value='1' >
<input type='checkbox' name='product_id1' value='1008' />
<br/>
Product 2:
<input type='hidden' name='quantity2' value='1' >
<input type='checkbox' name='product_id2' value='1014' >
<br/>
Product 3:
<input type='hidden' name='quantity3' value='1' >
<input type='checkbox' name='product_id3' value='1011' >
<br/>
<input name="submit" type='submit' value='Buy from 2CO' >
</form>

It is also very easy to add the ability for your customers to enter the quantity themselves as well. To do this we will replace this line:

<input type='hidden' name='quantity1' value='1' >

with the following:

<input name='quantity' type='text' class="ctrl-ed" size='5' >

Checkboxes can also be used to allow your customers the ability to purchase an add-on or option for your product. In this example, we have a product that you can purchase with the option of being a gift. First we start with our basic HTML snippet that is provided by the 2Checkout system.

<form action='https://www.2checkout.com/checkout/purchase' method='post'>
<input type='hidden' name='sid' value='XXXXX' >
<input type='hidden' name='product_id' value='1' >
Quantity
<input name='quantity' type='text' class="ctrl-ed" size='5' >
<br>
<input name="submit" type='submit' value='Buy from 2CO' >
</form>

To allow the customer to choose the gift option we need to first add the checkbox input that will be linked to the gift product. You will create this gift add-on in your account as another 2Checkout product. Let’s say this add-on option is given a product ID of 2. The following lines need to be added to the above form.

This is a gift:

<input type='checkbox' name='product_id2' value='2' >
<input type='hidden' name='quantity2' value='1' >

After reading this article, you should be able to add the checkbox input to your purchase forms.

You need to login before leaving a comment If you do not have an account, you can register one here.

Recent Posts from the Community:

Get Payments

posted by: dspzaman

Referring URL

posted by: hipdev

SPP suggestion

posted by: brakkar
More from the community »

Spotlight Supplier

Spotlight Supplier

Feng Shui Products


Popular Tags