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.

Reduced Shipping Coupon

mreeemreee Member
in Help edited September 2013
I am using the multiple flat rate shipping to charge a Domestic and international shipping rate.

I want to make a coupon that allows people in canada to get a reduced shipping rate, $5 instead of the $9.90 international rate.

I looked at the free shipping coupon as a starting point but I'm not sure.


Thanks!
Tagged:
Comments
  • fc_adamfc_adam FoxyCart Team
    @mreee,

    Essentially what you'd need to do is modify your custom flat rate shipping logic to first check if the coupon is present in the cart. Then if the customer is shipping to Canada and has that coupon present, you set the shipping rate accordingly. The free shipping snippet should give you an idea of how to check if a particular coupon is present. If you need a hand, if you could let us know what your store is so we can see your logic - that would be a good start.
  • I was planning to use the second option from the documentation.

    Would I change 0 to 5 here?
    function myCustomShipping() {
      if (fc_json.custom_fields[FCcode] == "true") {
        return 0;
      } else {
        // ADD YOUR CUSTOM FLAT RATE CALCULATIONS, RETURNING THE CALCULATED FLAT RATE LIKE:
        // var myShipping = 5;
        // return myShipping;
      }
    }
    

    I plan on using a coupon that will give them a discount on the product as well as this shipping discount. Does that complicate things?
  • fc_adamfc_adam FoxyCart Team
    @mreee,

    You'd just set the coupon to discount the amount you want on the product - and then account for the discount to the shipping within your javascript.

    Do you need to restrict the discount only applying to Canadian customers, or is it safe to assume that if they have the coupon, they can get the cheaper shipping too?
  • If they have the coupon they can get cheaper shipping. That makes it easier.

    If I generate multiple variations of a coupon does it make a difference?
  • fc_adamfc_adam FoxyCart Team
    @mreee,

    So taking your existing shipping logic from your checkout, you'd update it to this:
    /* BEGIN CUSTOM SHIPPING LOGIC */
    has_coupon = false;
    if(fc_json.hasOwnProperty('coupons')) {
    	jQuery.each(fc_json.coupons, function(i, coupon){
    		if(coupon.name.search(/free shipping/i) > -1) {
    			has_coupon = true
    		}
    	});
    }
     
    var country_code = (jQuery("#use_different_addresses").is(":checked") ? $("#shipping_country").val() : $("#customer_country").val());
    removeCustomShippingContainer(); // This call will make sure that when it updates, it starts fresh.
    var sub_tot = fc_json.total_price;
    if (sub_tot >= 10 && country_code == "US") {
      addShippingOption(3, 0, '', 'Free Shipping');
    } else if (country_code == "US") {
      postage = 4.9 * (fc_json.product_count);
      addShippingOption(1, postage, 'USPS', 'Standard');
    } else {
      if (has_coupon) {
      	postage = 5;
      } else {
      	postage = 9.9
      }
      postage = postage * (fc_json.product_count);
      addShippingOption(2, postage, 'USPS', 'International');
    }
    jQuery("#fc_shipping_methods_inner input[type='radio']:first").trigger("click");
    /* END CUSTOM SHIPPING LOGIC */
    

    This looks for a coupon that has a name that contains "Free Shipping" (case insensitive though) - and if that's present it sets the postage to 5 * product count, otherwise it stays as 9.9 * product count - for international shipping.
  • Thanks! Do I still need to add the code from the documentation to my cart and receipt?
  • fc_adamfc_adam FoxyCart Team
    Which documentation are you referring to there?
  • fc_adamfc_adam FoxyCart Team
    Ah no, that page doesn't apply to you at all.
Sign In or Register to comment.