Shipping Address Example
The following example shows how to generate a form that collects shipping address information. A live example is provided at the bottom of this page.
Create a new WordPress page using the following combination of HTML and WordPress shortcuts
[stripe_form_begin test=true] [stripe_form_amount amount="10.00"] [stripe_form_billing_info] [stripe_form_section_header title="Shipping Address"] <button id='copy'>Copy billing address</button> [stripe_form_section_row label="First Name" input="<input name='ship_fname' type='text' />"] [stripe_form_section_row label="Last Name" input="<input name='ship_lname' type='text' />"] [stripe_form_section_row label="Address 1" input="<input name='ship_address1' type='text' />"] [stripe_form_section_row label="Address 2" input="<input name='ship_address2' type='text' />"] [stripe_form_section_row label="City" input="<input name='ship_city' type='text' />"] [stripe_form_section_row label="State/Province" input="<input name='ship_state' type='text' />"] [stripe_form_section_row label="Zip/Postal Code" input="<input name='ship_zip' type='text' />"] [stripe_form_payment_info] [stripe_form_end] [stripe_form_receipt] <p><strong>Thank You, {fname} {lname}</strong></h4> <p><strong>$ {amount} is making its way to our bank account.</strong></p> <p>A receipt has been sent to <strong>{email}</strong>.</p> <p>Transaction ID: {id}</p> <p> Shipping Address: <br /> {ship_fname} {ship_lname}<br /> {ship_address1}<br /> {ship_address2}<br /> {ship_city}<br /> {ship_state} {ship_zip} </p> [/stripe_form_receipt]
Lines 4-19 in the above example add a new section to the payment form. The section has a title of Shipping Address
and collects the shipping information (first name, last name, address 1, address 2, city, state, zip
).
Lines 22-35 create a custom receipt. This receipt will be created and shown in the web page after the payment is successfully received. Notice the templating variables with the following format {variable}
where variable
corresponds to the names supplied to the input
elements.
The following jQuery can be used to wire up the ‘copy’ button that is defined on Line 5 in the above code.
<script type='text/javascript'> $('#copy').click(function(evt){ evt.preventDefault(); $('input[name="ship_fname"]').val(jQuery('input[name="fname"]').val()); $('input[name="ship_lname"]').val(jQuery('input[name="lname"]').val()); $('input[name="ship_address1"]').val(jQuery('input[name="address1"]').val()); $('input[name="ship_address2"]').val(jQuery('input[name="address2"]').val()); $('input[name="ship_city"]').val(jQuery('input[name="city"]').val()); $('input[name="ship_state"]').val(jQuery('input[name="state"]').val()); $('input[name="ship_zip"]').val(jQuery('input[name="zip"]').val()); }); </script>
To introduce special processing use the following code:
stripe_register_payment_end_callback('my_payment_end_callback'); function my_payment_end_callback($response) { // All the form variables are accessible in the $response array $to = $response['email']; $subject = 'Shipping Address Example'; $email = new DigLabs_Stripe_Helpers_Email(); $body = $email->createBody("Shipping Address Example", "This is a summary of a the data collected by the form.", $response); $email->sendEmail($to, $subject, $body); }
Line 1 uses one of the Stripe WordPress plugin’s functions to register a callback to provide special handling. In this case, the form variables are simply being emailed back to the person who submitted the form. Use your real email address below and give it a try.
[thkBC height=”600″ width=”500″ anchortext=”Give Me A Try” title=”Shipping Address Example” type=”inline” html_class=”button btn-mega btn-black” inline_id=”shipping_address”]cc = 4242-4242-4242-4242
cvc = 123
Thank You, {fname} {lname}
$ {amount} is making its way to our bank account.
A receipt has been sent to {email}.
Transaction ID: {id}
Shipping Address:
{ship_fname} {ship_lname}
{ship_address1}
{ship_address2}
{ship_city}
{ship_state} {ship_zip}
Stripe Payments WordPress Plugin
- $35
- East to setup. Ready to go in minutes.
- Securely collect payments: donations, invoices, recurring.
- WordPress shortcodes create simple or custom payment forms.
- Complete control over the form design.
- Customize the payment processing experience.
Additional Reading
Recent Posts
-
have_posts()) : $my_query->the_post(); ?>
- More...
Examples
- User Examples
- Shipping Address Example
- Donation Page Example
- Payment Options
- Recurring Payment Options
- Fixed or Recurring Payment Example
Check Out These Add-on Plugins
Support
Need help? Be sure to read the Additional Reading and Examples above. If you are still stuck you can contact supportQuestions
If you have questions, please feel free to contact us.Why Us?
Contact Us
312 Monte Cristo Circle
Verona, Wisconsin 53593
info@diglabs.com