Change subscription shipping address? And other issues.

GeoffreyGeoffrey Member
in Help edited November 2012
Hi. We recently setup subscriptions with Foxycart, and our subscription service delivers shippable product. We charge a flat fee for subscription with the cost of shipping rolled into it. We also sell non-subscription products, and shipping for those is treated on a flat rate basis for domestic, international and price-based free shipping thresholds. I have implemented the basic multiple flat rate shipping hack listed in the Foxycart documentation and this worked for us well before subscriptions were a factor. Our subscription service shouldn't have any shipping fee associated with it, and should not be factored to determine our free shipping thresholds in a customer's cart. The trouble is that if a customer puts a subscription in their cart, it is below the free shipping threshold and the custom shipping logic will add basic flat rate shipping to their cart. I initially thought I could solve this by very simply making a separate product category called "subscription" and setting its product delivery option to "No shipping". This has worked to some degree to manage the complexity of subscriptions and regular products being purchased at the same time. I have, however, just discovered that this does present some problems.

First off, I have a customer who emailed me saying that he could not see any option to enter a shipping address different from his billing address when trying to checkout with a subscription, and he then relayed the desired shipping address to me asking that I change it in his subscription record manually. I just looked around in the admin controls attempting to find a way to make this change, but I have not been able to find it, and instructions to do this do not appear to be provided in the Foxycart wiki document on subscriptions. How can I do this?

I also realized that perhaps my setting the product delivery option to "No shipping" on the subscription category has suppressed the whole shipping address section from checkout and subscription records. This is a problem. I thought of just changing the product delivery option back to "Shipped using a flat-rate fee" and setting the rate to $0, but then realized that the custom flat-rate shipping script is overriding that option. I'm not sure how to adjust the script to accommodate an exception for the subscription product category only. I want to continue using the custom shipping logic in place to offer flat rate shipping options based on country and cart total, but I also want to exclude the subscriptions category from that logic, and have Foxy Cart recognize subscriptions as shippable product with a fee of $0 so that it will allow customers to enter a shipping address separate from their billing address at checkout.

How might I best go about accomplishing this? Website in question, for reference, is http://verdanttea.com

Our subscription product is "Tea of the Month Club". Any help on this would be deeply appreciated. Many thanks for your time and consideration!

Geoffrey
Comments
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    Hi Geoffrey, yeah you definitely want to leave it as flat-rate with a cost of 0. What you do want to do, though, is inside of your multiple flat rate custom code you want to loop through each product and check it's category. If it's part of the subscription category, you can totally ignore it - pretend it isn't there. Does that make sense?
  • fc_adamfc_adam FoxyCart Team
    I also realized that perhaps my setting the product delivery option to "No shipping" on the subscription category has suppressed the whole shipping address section from checkout and subscription records.

    That's right - if only a product is present with 'no shipping' set, no shipping fields will be displayed.

    In terms of fixing that customer, you can either utilise the API to update that customers record (or use a system that hooks into the API and provides that type of functionality, @sparkweb built Order Desk which I believe provides that, he'll correct me if that's not the case :) https://foxytools.com/orderdesk/)

    The other option would be to switch the subscription back to flat rate of $0, and then provide the customer with an updateinfo link to load up the checkout and when they login they'd be able to enter in their shipping details and update their customer account.

    With your script, like @sparkweb said, you just need to remove the subscription for the calculations. As your tiers are based on total price, you'll need to remove the subscription cost from the total price. Something like this:
    var shippable_price = fc_json.total_price;
    var only_subs = true;
    for (var p in fc_json.products) {
      if (fc_json.products[p].category == "SUBSCRIPTION") {
        shippable_price -= fc_json.products[p].price;
      } else {
        only_subs = false;
      }
    }
    

    Put that before your custom logic tiers, and change any reference to checking what the fc_json.total_price is, to use the shippable_price value instead.

    You may also want to add a free shipping option if 'only_subs' is equal to 'true' and not show any other options.
  • GeoffreyGeoffrey Member
    edited November 2012
    @fc_adam - Thanks for the details! I got it to work with the snippet you provided. Although, I did have to make one adjustment to the suggestion you made. For some unknown reason the custom logic tiers would not properly parse the if 'only_subs' is equal to 'true' condition. I had to change the condition to if 'only_subs' is not equal to 'false', and then it worked. I have no idea why these two statements are not considered equivalent in the logic, but whatever... it works now.

    On another note, and I'm including @sparkweb on this question, I attempted to change the subscription customer's shipping address via Order Desk, and it appears that the change has definitely saved in that application, but when I check the transaction and subscription records in FoxyCart admin for that customer, the shipping address does not appear to have changed. Is it true that Order Desk does post back this data to FoxyCart through the API, or not? If not, can I just use the Unified Order Entry method with the updateinfo link for that customer to change it myself (now that I've switched the SUBSCRIPTION category back to flat rate $0)?

    Thanks for all your help guys!

    Geoffrey
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    @Geoffrey, Order Desk only changes the local version. FoxyCart doesn't let you change a past transaction as it is considered transactional history. What you can do is change the customer's address in Order Desk as that uses the API to connect directly to FoxyCart. I think the most reliable thing, though, is to use the UOE to update the subscription itself.
  • Thanks for the info, David. I will go ahead and make the change with UOE then.
  • fc_adamfc_adam FoxyCart Team
    @Geoffrey,

    If you had a line like this:
    if (onlysubs == 'true') { ... }
    


    You'd want that to be:
    if (onlysubs == true) { ... }
    

    Sorry, I should have made that more clear.
  • So I got this all to work just fine, but I've since realized that there is another layer of complexity that needs to be wrestled with. The subscription services that we offer are shippable and set to bill as "future subscriptions" on a specific day of each month. For customers in the US and Canada, we want there to be no shipping charge for the subscriptions, but for other international customers we want to set a flat rate shipping charge that will be applied with the future subscription. Here's what I've tried to do:
    function customShippingLogic() {
    		/* BEGIN CUSTOM SHIPPING LOGIC */
    				
                    var shippable_price = fc_json.total_price;
    		var only_subs = true;
    		for (var p in fc_json.products) {
    		  if (fc_json.products[p].category == "SUBSCRIPTION") {
    			shippable_price = shippable_price + 25 - fc_json.products[p].price;
    		  } else if (fc_json.products[p].category == "SUBSCRIPTION2") {	
    		  	shippable_price = shippable_price + 45 - fc_json.products[p].price;
    		  } else {
    			only_subs = false;
    		  }
    		}		
    		if (typeof(country_code) === "undefined") {country_code = "";}
    		new_country_code = (jQuery("#use_different_addresses").is(":checked") ? $("#shipping_country").val() : $("#customer_country").val());
    		if (country_code != new_country_code) { // The shipping country has changed!
    			country_code = new_country_code;
    			removeCustomShippingContainer(); // This call will make sure that when it updates, it starts fresh.
    			if (only_subs == true && country_code == "US" || only_gift == true && country_code == "CA") {
    				addShippingOption(1, 0, 'USPS ', 'Free 1st Class Shipping – ');
    			} else if (country_code == "US" && shippable_price >= 60) {
    				addShippingOption(1, 0, 'USPS ', 'Free Priority Shipping – ');
    			} else if (country_code == "US" && shippable_price >= 35) {
    				addShippingOption(1, 0, 'USPS ', 'Free 1st Class Shipping – ');
    				addShippingOption2nd(2, 7.50, 'USPS ', 'Priority Shipping – ');
    			} else if (country_code == "US" && shippable_price < 35) {
    				addShippingOption(1, 4, 'USPS ', '1st Class – ');
    				addShippingOption2nd(2, 7.50, 'USPS ', 'Priority Shipping – ');
    			} else if (country_code == "CA" && shippable_price >= 35) {
    				addShippingOption(1, 0, 'USPS ', 'Free 1st Class Shipping – ');
    			} else if (country_code == "CA" && shippable_price < 35) {
    				addShippingOption(1, 4, 'USPS ', '1st Class Shipping – ');
    			} else if (country_code != "US" && shippable_price >= 65 || only_subs == false && country_code != "CA" && shippable_price >= 65 ) {
    				addShippingOption(1, 0, 'USPS ', 'Free 1st Class International Shipping – ');
    			} else {
    				addShippingOption(1, 7.50, 'USPS ', '1st Class International Shipping – ');
    			}
    			 // Automatically select the first listed shipping option
    			 jQuery("#fc_shipping_methods_inner input#shipping_service_1").click();
    		}
    		/* END CUSTOM SHIPPING LOGIC */
    	} 
    	//]]>
    
    

    This works to a certain extent, in that it will not apply a shipping charge to subscription customers in the US or Canada, but will charge our flat rate shipping fee for international subscription customers. The only problem is that it charges the international customers a shipping fee up front at checkout before the "future subscription" is scheduled to begin, and then it will charge that shipping fee again when the subscription actually begins on a monthly basis. I need to somehow get the shipping fee applied to international subscriptions without charging them the $7.50 shipping fee at checkout when they first initiate their subscription, as they will be charged for the subscription and shipping fee again when the "future subscription" actually begins.

    Is there any way I can work this out? Just in case you're wondering, we use the future subscription start date option to keep all our order fulfillment processes organized, so reverting to the default subscription setting which starts charging when the customer completes checkout is not an option for us. If we were offering subscriptions to an application or other non-goods service, the default setting would make things easier, but as we are dealing with shipped goods the subscription charges need to be processed together as a batch.

    Any advise on how I might approach resolving this problem would be deeply appreciated. Thanks for your help!


    Geoffrey
  • fc_adamfc_adam FoxyCart Team
    @Geoffrey,

    Are all your subscriptions future-dated? And are your subscriptions only ever ordered on their own?
  • @fc_adam,

    All subscriptions (we have two currently) are future dated. The first one is scheduled to bill every 15th of the month, and the second is scheduled to bill every 5th of the month.

    As for your second question, the answer is no. We also sell stand-alone product that customers can also add to their cart with a subscription in it. Which adds another level of complication that I have done my best to address already with your help on code snippet I posted above. I have noticed that some customers who purchased non-subscription items at the same time as they purchased a subscription, and had an order total that remained under our free-shipping threshold, were charged shipping for their initial order (as intended), but also then set to be charged a shipping fee when their subscription started at the future date specified. I had to go into the foxycart admin subscription controls and reset those ones to have $0 shipping using advanced edit. That works fine, but I realize that I may miss it every now and then, which is not ideal.

    Complicated stuff... Do you have any suggestions for possibly making all this easier if I configure it a different way? Or is there an obvious script workaround to solve these issues?

    In any case, I appreciate the help!
  • fc_adamfc_adam FoxyCart Team
    @Geoffrey,

    So basically with the way the multiple flat rates work - it basically hooks off of the live rate javascript - but you define the values. We have some stuff on the checkout for handling future shipping, but you'll need to kind of fake it a little.

    So if it's just the subscription, in your tiers, set this:
    FC.checkout.config.futureShippingOnly = true;
    

    If it's a mixture of the two - that's where it can get a little funny to fake. Essentially you'll need to put anything relating to the subscription shipping in FC.checkout.config.orderFutureShipping and the rest can be done as it currently is.

    The tricky bit comes when trying to do both of those things, as it's already basically a hack as it is. To be able to do both you'll need to get pretty custom with how this snippet as a whole works. If you can keep it to just either the sub or normal products, you'd be able to get away pretty clean.
Sign In or Register to comment.