box deposit charge for new customers and guest checkouts

sunsurfsunsurf Member
in Help edited June 28
Hello,

My client has come to me with a tricky query.

This is for a website that delivers fruit and veg boxes.

She wants to know if its possible somehow to apply a box deposit charge of $5.00 for new customers or for those that checkout as a guest. Is that possible with FoxyCart? If so, how could we implement it?

Thanks for your help.
Comments
  • fc_adamfc_adam FoxyCart Team
    @sunsurf,

    Interesting question. You can detect if a customer is creating a new account on the checkout, or checking out as a guest, using javascript. I see you're currently on version 0.7.2 for the store, something like this should detect that specific set of scenarios:
    <script>
    jQuery("#is_anonymous_0, #is_anonymous_1").click(checkCustomerType);
    jQuery("body").ajaxComplete(function(event, request, settings) {
    if (settings.url.indexOf('CheckEmail') != -1) {
    checkCustomerType();
    }
    });

    function checkCustomerType() {
    if (jQuery('#is_anonymous_1').is(":checked") || (jQuery('#is_anonymous_0').is(":checked") && jQuery("#email_found").val() == "false")) {
    // Customer is guest or creating new account
    } else {
    // Customer has an existing account
    }
    }
    </script>
    The next question is how to track the additional fee. If you were calculating shipping costs, the fee could be bundled into that - but it looks like your categories are set up as "not shipped" so that wouldn't work.

    As you're using the purchase order method, and charging the customer manually - would it be enough to include a custom checkout field to note that the additional fee will be included - and then manually include it when processing the charge? It means it wouldn't be included in the order total itself, the person executing the charge would need to check for that custom field in the transaction to account for it.

    Alternatively - you could also add a coupon in the background, and set up the coupon to increase the order by $5 rather than decrease (like 1+5 instead of 1-5). The checkout totals would need to be updated to account for the new coupon after being added, and it'd need to be removed if the customer ends up logging in, but that could work too.

    We don't support coupons on the checkout in 0.7.2 - but we do have snippet on our wiki that adds in a coupon field detailed here: https://wiki.foxycart.com/snippets/checkout/adding_a_coupon_code_field. You wouldn't want it to show the coupon input field (you could hide that with CSS), but you could use that as a basis for adding the coupon in the background using javascript.

    As an aside - would your client have any interest in upgrading their store to 2.0? There has been a number of great new features and improvements since we released 0.7.2 in 2012, including new responsive default templates, lots of new payment gateways supported, improved subscription functionality, additional configuration options and lots more. If you'd like we can also review your site and send you an overview of what would be involved with upgrading the store. If you'd like that, if you could email our helpdesk we can get that created for you.
  • sunsurfsunsurf Member
    edited June 29
    Thanks so much for the in depth answer! The more I think about it I really like your suggestion of the note on the checkout page. I think given payments are processed manually, its probably the most KISS Theory approach. I am just running it past the client and will confirm.

    I think she's a bit scared about what's involved - the cart is very heavily modified so it seems a big job. I would hate to lose any of the awesome js mods you provided for us, and probably lots of css tweaking to maintain current visuals needed too. We have had a few discussions but at this stage I don't think she wants it actioned.

    Thanks again.
  • fc_adamfc_adam FoxyCart Team
    @sunsurf,

    Sometimes the simplest solution is the best!

    In terms of the upgrade - if you ping our helpdesk, we can give you the upgrade plan and you'll have a clear idea of what'd be involved. That would also cover any customisations on the checkout, how they'd need to be approached or if they're covered by new features we've added since. At this point 0.7.2 is a very old version - and even making an incremental upgrade to a more recent version like 1.1 would be an excellent move to make and that would involve a lot less breaking changes. We can provide advice on that too as part of the review.
  • sunsurfsunsurf Member
    edited June 30
    Agreed, thanks Adam.

    I was hoping to add a required checkbox accepting the deposit. I tried this code but it didn't work on clicking the submit button. Any ideas on how to get it working as a required field? Thanks for any help.

    <div class="uof_foxbox">
    <div class="uof_foxbox_row">
    <input id="Deposit_0" name="Deposit" type="checkbox" value="deposit understood" class="fc_required"/>
    <label for="Deposit_0">Understood<span class="fc_ast">*</span></label>
    <label for="Deposit_0" class="fc_error" style="display:none;">Please check the deposit checkbox</label>
    </div>
    <div class="clear"></div>
    </div>
    Ok thanks Adam. I went a little through that process and we received a report but then I got radio silence from the client. Its really in her court and I don't think it's at the top of her list for the moment. Having said that, I wish wish wish wish it was easy to replicate an FC store for testing purposes - that's one way to make the process a little less intimidating.
  • fc_adamfc_adam FoxyCart Team
    @sunsurf,

    Looks like there may be a bug somewhere in the older 0.7.2 code related to the required fields. Try dropping the _0 from the ID and the two for attributes - and see if that works.
  • sunsurfsunsurf Member
    edited July 3
    Thanks @fc_adam.

    I tried your suggestion (code updated per below) - it seems to work (guessing) but the error message does not display (so its confirm to tell if it works)


    <div class="uof_foxbox">
    <div class="uof_foxbox_row">
    <input id="Deposit" name="Deposit" type="checkbox" value="accept deposit" class="fc_required"/>
    <label>I accept<span class="fc_ast">*</span></label>
    <label class="fc_error" style="display:none;">Please accept the deposit</label>
    </div>
    <div class="clear"></div>
    </div>


    Presuming that is working, any idea on how to display the error?

    Thanks again for your help with this.

    (p.s. I have removed that from the checkout page temporarily so customers don't get stuck without the error message)
  • sunsurfsunsurf Member
    edited July 4
    Hi Adam,

    I got it working. To show the deposit it needed the for attributes like so:
    <div class="uof_foxbox">
    <div class="uof_foxbox_row">
    <input id="deposit" name="deposit" type="checkbox" value="accept deposit" class="fc_required"/>
    <label for="deposit">I accept<span class="fc_ast">*</span></label>
    <label for="deposit" class="fc_error" style="display:none;">Please accept the deposit</label>
    </div>
    <div class="clear"></div>
    </div>
    So it was the 2 x label=for... with no _0 that worked for me.

    Thank you again for your help.
  • sunsurfsunsurf Member
    This is solved (but I can't work out how to mark it as solved.)
  • fc_adamfc_adam FoxyCart Team
    @sunsurf,

    Thanks for letting us know - and sorry for not being clearer in my previous post! I had meant dropping the _0 portion from both the ID and the for elements - but reading it back, I can see how it reads as remove the _0 from the ID and also remove the for elements. Sorry about that!
  • sunsurfsunsurf Member
    edited July 4
    Hehe! Funny. Well, I proved the other way didn't work :)
    Thanks again.
Sign In or Register to comment.