by
KK » Fri Mar 15, 2013 10:12 pm
Hi,
As you rightly said, it is the checkout.php that will need modifications.
If you take a look at the file (as it ships with the example site), you'll find that the 'Continue to PayPal' button simply submits a Couch form and we use the form's success condition to redirect to PayPal
- Code: Select all
<cms:form method="post" anchor='0'>
<cms:if k_success >
<cms:pp_payment_gateway
shipping_address="<cms:if "<cms:pp_count_shippable_items />" >1<cms:else />0</cms:if>"
empty_cart='0'
/>
</cms:if>
<div class="checkout-box">
<cms:input name="paypal" class="button checkout-button" type="submit" value="Continue to PayPal" />
</div>
</cms:form>
Since the form is a regular Couch managed one, we can very easily add any addition fields to it (e.g. the email and address fields in your case). In the success condition, we can then use the submitted form values and the
pp_cart_items tag to loop through the items in cart to create the email message.
Following is the modified form:
- Code: Select all
<cms:form method="post" anchor='1'>
<cms:get_flash 'success_flash_msg' />
<cms:if k_success >
<cms:send_mail from='sales@yoursite.com' to=frm_email bcc='you@yoursite.com' subject='Your order with XYZ.com' debug='1'>
Thank you for your order, <cms:show frm_name />.
Your order has been confirmed and is being processed. Here is the summary:
Items Ordered:<cms:pp_cart_items>
<cms:show title />. <cms:pp_selected_options separator=', ' /> (<cms:show quantity /> qty) - $<cms:number_format line_total /></cms:pp_cart_items>
<cms:if "<cms:pp_discount />">Discount: -$<cms:number_format "<cms:pp_discount />" /></cms:if>
<cms:if "<cms:pp_shipping />">Shipping: $<cms:number_format "<cms:pp_shipping />" /></cms:if>
<cms:if "<cms:pp_taxes />">Taxes: $<cms:number_format "<cms:pp_taxes />" /></cms:if>
Outstanding Amount Payable: $<cms:number_format "<cms:pp_total />" />
Delivery Address:
<cms:show frm_address />
</cms:send_mail>
<cms:set_flash name='success_flash_msg' value="<p class='success'>Thank you for your order!</p>" />
<cms:redirect k_page_link />
</cms:if>
<cms:if k_error >
<div class="error">
<ul>
<cms:each k_error >
<li><cms:show item /></li>
</cms:each>
</ul>
</div>
</cms:if>
<cms:fieldset label='Shipping details'>
<cms:input type="text"
name="name"
label="Name"
maxlength="100"
required='1' />
<cms:input type="text"
name="email"
label='Email'
maxlength="100"
validator='email'
required='1' />
<cms:input type="textarea"
name="address"
label='Address'
cols="35"
rows="5"
required='1' />
</cms:fieldset>
<div class="checkout-box">
<cms:input name="paypal" class="button checkout-button" type="submit" value="Buy" />
</div>
</cms:form>
The above form sends the following (sample) message on successful transaction:
- Code: Select all
Thank you for your order, Sherlock Holmes.
Your order has been confirmed and is being processed. Here is the summary:
Items Ordered:
Paper Airplane. Color: Red, Custom Text: zz (1 qty) - $6.00
Raised Relief World Globe. Illuminated: No, Stand Type: Tabletop, Stand Material: Plastic (1 qty) - $50.00
Shipping: $15.00
Taxes: $7.10
Outstanding Amount Payable: $78.10
Delivery Address:
221B Baker St, London,
Greater London NW1 6XE,
United Kingdom
Hope this helps. Do let us know.
Thanks.