Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
Hello,

I've a question concerning additional paying options in the new cart add-on. I only need the option to output the cart content (a list of items + price) and give the user the option to add his shipping address, email and phone. When the user press the buy or submit button a e-mail should be generated with the details of the order and send to the buyer and the seller.

I know I have to modify the checkout.php file and get rid of the paypal gateway as mentioned in the tutorial part1. But how can I list the cart items and include them with the shipping address and some additional text into a e-mail?

thanks a lot
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.
Thank you very much for your help Kamran!
this post is quite old but there is an additional question. How can I empty the cart when the user did press the buy button.

I just tried <cms:pp_payment_gateway empty_cart='1' />
Code: Select all
<cms:if k_success >
<cms:send_mail from='xxx' to=frm_email to='xxx' bcc='xxx' subject='Ihre Bestellung von xxx' debug='1'>
<cms:embed 'bestaetigungsmail.php'/>
</cms:send_mail>

<cms:pp_payment_gateway empty_cart='1' />
           
<cms:set_flash name='success_flash_msg' value="<div class='success alert alert-success'>Vielen Dank für Ihre Bestellung! <p>Folgendes Mail wurde Ihnen zugeschickt.</p><br><pre><cms:embed 'bestaetigungsmail.php'/></pre></div>" />

<cms:redirect k_page_link />
</cms:if>


But this emptys the cart before the order is been send out :o

edit: Always the same, as soon as I have a question and post it here I find the answer myself.
I shifted the <cms:pp_payment_gateway empty_cart='1' /> to the line below the success_flash and it was working perfectly.

Great thing these couch Cart!!! Thank you very much
4 posts Page 1 of 1