Support » Plugin: MarketPress - WordPress eCommerce » Free shipping on some products

  • Resolved Robin W


    I’m using marketpress lite 2.5.1

    In use table rates for shipping based on price, and know that I can add extra costs for a particular product.

    But I’d also like the opposite – to set “free shipping” for particular products.

    Is their a way I can do this either something I missed, by upgrading or by tweaking code or via a plugin?

Viewing 15 replies - 1 through 15 (of 20 total)
  • I’m afraid that out of the box this can’t be done, and I am not aware of any plugins that can do this.
    However, you could edit the shipping gateway file and add exceptions for these products… I ‘ve never tried anything like that, but I don’t see why it wouldn’t be done.
    Basically you could check the cart and if the IDs of some products is there, then remove their value from the cart total on shipping calculation.

    I hope that helps!


    Thanks, suspected that would be the case, and will delve into the shipping php’s !

    Ann McG


    I’m also interested in this solution – we sell festival tickets and merchandise. Flat rate shipping is fine for merch, but excessive for tickets. Would like to disregard shipping for that item. If you don’t mind sharing your solution, we’d love it!


    Yes exactly the problem I had a couple of months ago when I stumbled across a solution outside of ecommerce, which works really well. I am part way through writing it up, hope to come back in the next 24 hours with a documented solution !

    That sounds interesting! I’m intrigued to see what you come up with!

    Firstly, suggest you read this all though, so that you know where you are headed, as it may at first seem long and complicated, but like most things, once achieved it is easy in retrospect!

    Obviously I don’t know your level of expertise, so if some of this is laboured excuse me, and if some is too vague, come back with questions!

    I presume you have a paypal account.

    I will also presume you have an FTP product such as filezilla, and are able to upload and download files. I’ll also presume you know how to use notepad or equivalent to edit a file. If you don’t know these, google “how to use filezilla video” or similar – there are lots of videos that’ll take you through this.

    End results
    From users points of view:
    They access a form within a page (or post) which asks whatever q’s you need (each of which you can set up as mandatory or optional)
    They select membership type within this – or the Q’s make the selection for them (up to you how you set this up)
    They click a payment button
    They are taken to paypal’s payment page with the appropriate words (eg single membership, joint membership) and the correct amount for that type.
    They pay, and go to a thankyou page

    From your point of view:
    You receive an email with answers to the Q’s
    You receive a paypal payment confirmation
    You can then send welcome pack, set up user, do nothing etc.

    If you want to see what this looks like for real, go to my test site

    Membership – Join or Renew Here

    Feel free to complete the boxes with rubbish and you can quite happily click the payment button to be taken to the Paypal page, but if follow the payment all the way through, I’ll get the money, so stop there !

    You’ll see the last two boxes – membership and newsletter types – combine to determine the amount to be paid.

    OK so if this is what you’re after carry on…

    CformsII is not the easiest forms package to get into setting up, but it does have the neat trick of being able to do things conditional on what answers are given, hence why I used it.

    In terms of getting it working, the following steps are needed :

    1. Download plugin to your PC
    2. Upload to your website
    3. Activate
    4. Set up form
    5. Choose styling
    6. Set up entry page
    7. Set up exit page
    8. Edit my-functions plugin
    9. Go live

    Steps 1 through 4 are best covered by watching the following video on cforms, this shows you installing and takes you through how to set up a form.

    When you watched this go ahead and install and set up your form.

    When you have done so, go back to the video and take note of the following ;

    Setting up the email bit, as this is how you get the data ! (around 6:30 on the video)
    Setting up messages – I changed “submit” to “Payment” and the success message to “Thank you for your application, proceeding to payment…” to make it clear that you are progressing to the money bit.

    Finally, when they have completed the form, you’ll need a “success page” – you’ll need this for two reasons. Firstly to thank them for filling in the form, but secondly because paypal terms insist you have a confirmation page following payment.

    Mine looks like this

    Membership Payment Page

    You need to put this url into “redirect” part in “core admin” section of the form – this will then come into play after they have made payment.

    CSS Styling

    Having created your form, you can try it by adding it to test page and see what it looks like. At the moment it’ll just go from the form to the post payment page when you click “submit” or “payment” or whatever you call the button – don’t worry we’ll add the hook to payment in between these stages later.

    You may not like how the form is styled – however in the dashboard>cformsII>styling you’ll find different styles you can use, I liked wide_form.css, so chose this.

    If you’re clever you can change the styles via an editor at the bottom of this screen.

    Adding Payment

    Ok, so now that you have created your form, got it looking how you like and all working, finally you can add the payment part. I say finally, because the hook it uses depends on knowing the order of the questions, so you need to have finalised this otherwise you’ll need to keep doing changes to the php file we are about to change.

    This is where we need Filezilla or equivalent – your host provider might have this capability built in – in essence you’re looking for package that lets you do FTP – file transfer protocol.

    As state above if you don’t have one, then filezilla is a popular choice – simply download the Client version, google for videos on how to do this, but make sure it’s the CLIENT one you download.

    Once connected you’ll need to find the current my-functions file in the cforms plugin.

    Navigate the following


    Save this away to your local PC as a backup.

    Then create a new my-functions.php and put the following code into it
    function my_cforms_logic($cformsdata,$oldvalue,$setting) {

    //### If you’re unsure how to reference $cformsdata use the below @mail call to send you the data array
    @mail(‘’, ‘cforms my_action test’, print_r($cformsdata,1), ‘From:‘);
    if ( $setting == “redirection” ){

    $userfield = $cformsdata[‘data’][$cformsdata[‘data’][‘$$$28’]];
    $userfield2 = $cformsdata[‘data’][$cformsdata[‘data’][‘$$$29’]];

    if ( $userfield == ‘Family’ && $userfield2==’By Email’)
    return ‘’;

    if ( $userfield == ‘Family’ && $userfield2==’By Post’)
    return ‘’;

    return $oldvalue; // If you use this function, this MUST be the last statement!


    Then save it and upload it to replace the existing file ie at wp-content/plugins/cforms

    Then run your membership form, click the submit/payment button. This will now access the new my-functions and send you an email with what fields have what ID no,.s.

    Look at the email and what you are looking for are the $$$ no.s say for instance members is $$$14

    Now go back to your my-functions.php in notepad.

    Comment out the @mail line, and uncomment the bits between the /* and */

    In this version I am looking at two parameters and setting the return dependant on this combination
    If you have only one parameter then change accordingly.

    You’ll see that the if statement then sends the user to the paypal website with lots of parameters in, including your paypal account, item-name, amount, shipping, and return url.

    Now on the return line you need to replace the XXXXXX and YYYYYY

    The XXXXX is you email address that you use for paypal. But this needs to be phrased so that the URL doesn’t contain any punctuation which is used for coding.

    So we need to replace the @ symbol with %40 and the full stops/periods with %2e

    So becomes fred%40mail%2ecom

    Then we need to change the return url (this is where paypal will send the user back to after payment) again taking out slashes and fullstops/periods. Slashes are %2f, and colons %3a




    Finally change the item_name in this line to what you want , and alter the amount, and you have a working couple of lines.

    Then just repeat these two lines (the one starting IF, and the one saying return) for all your other conditions, changing item_name and amount as needed.

    Upload and test.

    Anything not clear – come back and I’ll try and help further !

    ok, so 5 days later, and whilst finalising a route, I stumbled across some other code which led me down an entirely different route.

    Many days of sheer frustration, and I cracked it, end result is really easy, but boy if you are not an expert programmer, it is really hard to piece together lots of helpful posts into a single “how to”.

    I always feel that wordpress and associated products are a bit like a car. The codex and documentation gives masses of detail about say the engine, but nothing tells you that this bit helps it go, and that bit helps it stop. A fully documented steering wheel diagram tells you nothing about what it’s for, and how you work it !

    Anyway, can’t complain as many people write this stuff for us for free, and coding is 100 times as fun as documenting!

    So in the end I have written a plugin, which does two things;

    1. Creates a meta box on each product page that gives a check box for free shipping
    2. Creates a new table rate that amends the table-rate calculation to check for free ship items and excludes them from the calculation.

    To go with that I have spent ten minutes creating a website that you can download it from

    Plugin is available at

    Look for the freeship plugin page and download
    Then go into plugins>add new>upload and upload the zipped file, then activate etc.

    To get the shipping rates to work, you’ll need to change from ‘table rate’ to “fs table rate” then create the table.

    I will add the readme and other bits to make it loadable from wordpress in the next few weeks.

    The coding is fine, but not the prettiest, I am only a junior at this !

    Any other feedback welcome.

    I will be honest with you, I haven’t read all of your last two posts… it’s 9pm where I am and I’m afraid at this time of day a skim read is all I can offer…. however I notice from your latest post that you managed to fix your issue, and the fact that you have provided a downloadable version of your results is great! Nicely done!

    No sweat – know you guys are busy, and was posting for general benefit 🙂



    WPMU DEV Support Staff

    Thanks for posting Robin, that’s great and I’m glad you got this sorted out too! 🙂

    Vince L


    Robin W thanks for your post! I am a rookie at this and was successfully able to install your plug-in, activate it and configure. Nice job!

    I do have one questions/request; what if I only wanted to offer free shipping on a specific product, but limit it to a specific country? i.e. USA only. All other countries would have Flat Rate apply…
    Vince L

    Robin W



    Will leave this in my inbox – I wrote that plugin a while ago, and will need to get my head back around what it is doing, should be possible, but give me a few days to have a look.

    If I haven’t come back by next Thursday, post again and it’ll make me feel guilty !

    Robin W


    Ok had a quick look.

    If you know how to edit files then edit


    (save the original down to your PC in case it doesn’t work !)

    You find on line 268 the following code

    //******shipping_values array added to calculate if free shipping set
    	$shipping_values = array() ;
          foreach ($cart as $product_id => $variations) {
          foreach ($variations as $variation => $data) {
    	$fs = get_post_meta($product_id, 'fsFreeShip', true);
    		if($fs !=='on') {
    		$shipping_values[] = $mp->before_tax_price($data['price'], $product_id) * $data['quantity'];
             $total = array_sum($shipping_values) ;
    //*****then back to the original code

    paste the following over that to replace that section

    //******shipping_values array added to calculate if free shipping set and country is US
    	$shipping_values = array() ;
          foreach ($cart as $product_id => $variations) {
          foreach ($variations as $variation => $data) {
    	$fs = get_post_meta($product_id, 'fsFreeShip', true);
    		if($fs !=='on') {
    		$shipping_values[] = $mp->before_tax_price($data['price'], $product_id) * $data['quantity'];
    		} elseif ($country!=='US') {
    		$shipping_values[] = $mp->before_tax_price($data['price'], $product_id) * $data['quantity'];
    	   } else {
             $total = array_sum($shipping_values) ;
    //*****then back to the original code

    This will then only allow free shipping in the US
    I haven’t tested this, so it may not work, but I think it should, but you’ll need to test. if it doesn’t come back and I’ll look again.

    If you are not into editing code, please come back, and I’ll cut it into another plugin after the weekend but only if I need to !

    Vince L


    I got side tracked; editting code is a bit beyond my capabilities… afraid I might break something.

    Robin W


    Ok, I’ll update the plugin and post back when I have done it

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Free shipping on some products’ is closed to new replies.