ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Add or Subtract Tax and/or Shipping from Simple Commerce {add_to_cart} URL links

January 04, 2010 9:38pm

Subscribe [3]
  • #1 / Jan 04, 2010 9:38pm

    jayf

    41 posts

    Thought others might find this useful:

    The Simple Commerce module outputs simple PayPal add-to-cart links. When someone clicks one of these links on your site, an item is added to the user’s PayPal cart and it inherits your PayPal account’s default settings for shipping and tax calculation.

    On a site we created, this worked great since all of the products had the same tax and shipping rules, which were set in PayPal. That is, until today, when the site started selling a few services, which need to have no tax or shipping costs applied (in this case).

    So, we needed a way to override the tax and shipping on these couple items. Fortunately, PayPal allows a number of settings to be overridden via URL parameters, that are documented on their HTML Variables for Website Payments Standard page.

    To add extra variables to the link generated by Simple Commerce, one need simply append them as URL parameters, like &tax=0. The ExpressionEngine template code for this looks like:

    <a href="http://{add_to_cart_url}{if">Add to Cart</a>

    In this case, we’ve created two custom fields, tax and shipping, that appear for in the weblog we use for product entry in ExpressionEngine. We then output those fields into our template, used in the conditionals shown.

    Works great, and it’s simple.

    There is another way to get more full control over the PayPal links you output. This is well described by Ingmar Greil in his 2007 forum post PayPal, the Simple Commerce Module and you and in summary form in the Advanced PayPal entry on the ExpressionEngine wiki. Be sure to take a look at those if you need even more control.

  • #2 / Apr 24, 2010 1:52am

    Marco Angeli

    34 posts

    Very useful tip, only one thing to note (from paypal integration guide):


    To enable overrides of shipping rates:
    1. Log in to your PayPal account at https://www.paypal.com.

    2. Click the Profile subtab.
    The Profile Summary page appears.

    3. In the Selling Preferences column, click the Shipping Calculations link.
    The Shipping Calculations page appears

    4. Click the checkbox labelled Click here to allow transaction-based shipping values to
    override the profile shipping settings listed above (if profile settings are enabled).

  • #3 / Apr 27, 2010 1:25pm

    resonate4fe

    6 posts

    Hey JayF, thanks for posting this. I’ve been trying to pass a few variables to Paypal through the SCM through this same {add_to_cart_url} link also.

    I went through Ingmar’s posts and a few others but thanks to this post, I’m now able to pass the weight variable over to paypal.

    My question is, how do i pass the option on0 variable of size to paypal. This is what I have so far.

    {exp:simple_commerce:purchase entry_id="{entry_id}" success="site/success" cancel="site/index"}
    
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="paypal">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="cmd" value="_cart">
    <input type="hidden" value="http://www.resonate4fe.com/index.php?ACT=20" name="notify_url" />  
    <input type="hidden" value="http://www.resonate4fe.com/orders/thankyou" name="return" />  
    <input type="hidden" value="http://www.resonate4fe.com/" name="cancel_return" />
    
    <input type="hidden" name="item_name" value="{title}" />
    
    <input type="hidden" name="weight" value="{weight}" />
    <input type="hidden" name="business" value="[email protected]"/>
    <input type="hidden" name="currency_code" value="USD"/>
    
    <input type="hidden" name="item_number" value="{item_id}"/>
    <input type="hidden" name="add" value="1"/>
    <input type="hidden" name="upload" value="1"/>
    <input type="hidden" name="no_shipping" value="2"/>
    <input type="hidden" name="no_note" value="1"/>
    <input type="hidden" name="undefined_quantity" value="1"/> 
    
    <input type="hidden" name="on0" value="Size">Size:
    <select name="os0">
    <option value="Select a Size">Select a Size</option>
    {if small}
    <option value="small">small</option>
    {/if}
    {if medium}
    <option value="medium">medium</option>
    {/if}
    {if large}
    <option value="large">large</option>
    {/if}
    {if xlarge}
    <option value="xlarge">xlarge</option>
    {/if}
    {if 2xlarge}
    <option value="2xlarge">2xlarge</option>
    {/if}
    </select>
    
    </form>
    
    <a >Add to Cart</a> 
    
    {/exp:simple_commerce:purchase}

    for the life of me I can’t figure out how to pass that on0 varible to paypal, I’ve tried to use the image button instead but that’s even worse.

    any thoughts? thanks.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases