The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

Promotional Orders

jaushmanjaushman Member
in Help edited November 2011
Our client is asking for the ability to create sample and promotional orders which they send out at no cost. We are hoping to use the existing FoxyCart checkout process to allow for easy integration into their already existing order fulfillment backend.

We've created a coupon code that gives them a 100% discount for all products on an order. The issue I've encountered is with shipping. Our client wants to be able to select from any of the live shipping services returned for both domestic ad international orders (overnight, 2-day, etc) but needs the price to be $0.00 for all shipping services.

Using the code below (which is a variation on this functionality I've seen recommended in other posts) I loop through the shipping services returned by the live shipping feed and set $0.00 for shipping on each service. When I select any of these services I get $0.00 for shipping and the order total which correctly removes the credit card form and displays "No payment needed". However, when I attempt to place the order, FoxyCart errors back to me that the verification code and debit/credit card number are required.
jQuery("#fc_shipping_methods_inner").ajaxComplete(function(event, request, settings) {
    // Remove prices for sample orders
    if (fc_json.custom_fields.sample_order) {
        $("input[name^='shipping_service']").each(function(i) {
            var curr_shipping = $(this).val().split("|")[0];
            var new_shipping = curr_shipping + "|0.00";
            $(this).val(new_shipping);
        });
        $(".fc_shipping_cost").remove();
        $(".fc_shipping_divider").remove();
    }
});

Note: If I select the free ground shipping service I am able to complete an order.

Is my approach all wrong? Any other ideas on how this could be accomplished?
Comments
  • brettbrett FoxyCart Team
    Hey @jaushman.
    This definitely should be doable, but I think the issue is that by changing the shipping values after the fact, the js validation is still thinking that it's not a $0 order.

    I do know that this just came up a few weeks ago, and that @fc_adam created some code for it, but he's out for the next few days.

    What I might try is (if you haven't) going off the multiple flat rate shipping code:
    http://wiki.foxycart.com/snippets/shipping/tiered_flat_rate_shipping
    That might help, but you'd want it to only apply if a coupon is present, right? I think that'd be doable.

    If that's the script you're already working off, maybe it needs something else, but that script is probably the most solid and flexible place to get started.
  • Thanks for the idea @Brett.

    This doesn't feel act a javascript validation issue as the errors don't get raised until the page refreshes. I was assuming it was server side validation.

    Our client is pretty set on being able to zero out the rates returned by live shipping so they don't have to guess at what shipping services are available in various areas. Which rules out the tiered flat rate shipping idea. Maybe @fc_adam can shed some light when he returns.
  • fc_adamfc_adam FoxyCart Team
    @jaushman,

    Sorry - I was away a couple extra days - could you whisper me a link to your store and the coupon code you're using? I'll take a look at your setup and see what comes up.
  • @fc_adam

    In the interest of simplifying things I've commented out my FC.checkout.override. That leaves me with the following function which attempts to set $0 on shipping:
                jQuery("#fc_shipping_methods_inner").ajaxComplete(function(event, request, settings) {
                    // Remove prices for sample orders
                    if (fc_json.custom_fields.sample_order) {
                        $("#fc_shipping_methods_inner input[name='shipping_service']").each(function(i) {
                            var curr_shipping = $(this).val().split("|")[0];
                            var new_shipping = curr_shipping + "|0.00";
                            $(this).val(new_shipping).siblings("span.fc_shipping_cost").html('<span class="fc_currency_symbol">$</span>0.00');
                        });
                    }
                });
    

    Unfortunately, I'm still seeing the same validation errors on any shipping option except for Free Ground.
  • fc_adamfc_adam FoxyCart Team
    @jaushman,

    I just tried that code on a test checkout of mine, and it's working fine - so there must be something in your customisations that is interfering with the script.

    Can you perhaps try removing your all your custom javascript, trying with just the above, and then add back in your custom javascript to see what stops it from working?
  • @fc_adam,

    Thanks for your help getting this sorted out. After much testing I finally found a solution. Turns out that we had a $2.00 handling fee setup on the default category. Removing the handling fee in the FoxyCart admin allowed us to correctly set the shipping prices to $0.00 on all live shipping rates.
  • fc_adamfc_adam FoxyCart Team
    @jaushman,

    Ah! That would do it, glad you got it sorted mate.
Sign In or Register to comment.