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.

FC.checkout.config.orderShipping not changing

troutoiltroutoil Member
in Bugs & Feature Requests edited January 2011
Hi there, I'm having a hard time adding a handling fee for a gift card. I set FC.checkout.config.orderShipping, but then it isn't reflected in the final price. Any guesses?
Comments
  • ChuckTrukkChuckTrukk Member
    edited January 2011
    I have been using this method as well. But this method just recently stopped working as well for me.

    I'm using 060 on this site
  • brettbrett FoxyCart Team
    @ChuckTrukk, can you say when it stopped? There should be no changes to v0.6.0 that'd impact this.
  • fc_adamfc_adam FoxyCart Team
    @ChuckTrukk,

    It seems to be working fine for me, but maybe try altering orderFlatRateShipping as opposed to orderShipping when you set the shipping value.
  • I'm using 0.7.0 and still can't get it to work. I change the value of both orderFlatRateShipping and orderShipping, but the values are not reflected when the price is updated, nor are they reflected when the order is placed.
  • ChuckTrukkChuckTrukk Member
    edited January 2011
    @brett,

    My js was modifying FC.checkout.config.orderShipping based on some variables. It worked. Now FC.checkout.config.orderShipping seems immutable.

    @adam
    I thought the same thing - "it's working now". But it's not. it only "looks" like it works now. In the checkout page, the Shipping total shows $0. But when you pay/checkout, the shipping charge was actually $2.99 in our case.

    So to reproduce
    - Add six items to cart (I whispered links in the other thread)
    - Go to checkout page. It shows shipping as 0.
    - Actually checkout, and the default shipping was applied.

    I've used the code many times. And didnt change it. I really think this is a bug.

    PS - I tried both orderFlatRateShipping and orderShipping
  • It looks to me like the value of FC.checkout.config.orderShipping and FC.checkout.config.orderFlatRateShipping isn't effecting my order total at all.

    When I check the value of either variable (after choosing a shipping option) I come up with 0.

    When I add my Gift Card Fee to those values and recheck them they reflect only the Gift Card Fees (ex: .48), but the total isn't updated.

    -B
  • fc_adamfc_adam FoxyCart Team
    @troutoil, can you send us a link to your store? It's harder to debug what's happening without seeing what's going on behind the scenes (and sorry for not responding to yours earlier, I missed your first post!) Whisper it to us if its private (using the "whisper your comments to" box above the post box)

    @ChuckTrukk, try setting your flat rate shipping value in the admin to 0.00 instead of 3.99. Having a value above 0.00 caused issues for me in some testing just now.
  • lukeluke FoxyCart Team
    @CheckTrukk are you sure nothing changed on your end? We haven't touched anything in checkout.js for 060 and the changes Fred made to api_json.php couldn't explain what you're seeing. Looking at the source of your code, I see this:
    // Changed from 'FC.checkout.config.orderFlatRateShipping' to 'FC.checkout.config.orderShipping'
    		FC.checkout.config.orderShipping = shipping_cost + FC.checkout.config.orderHandlingFee;
    
    When was that change made? If you crack open checkout.js you'll see that config.orderShipping gets modified quite a bit throughout the execution of the checkout process so that might explain why your value is getting blown away. If you're wanting to modify the amount of the flate rate that's involved, the value that is commented out seems like the value you want to work with.

    Then again, it's almost 1am and I'm pretty tired so I could be completely missing something.
  • lukeluke FoxyCart Team
    @troutoil It looks like you're using live shipping rates and you don't currently have a handling fee configured. If you just want a handling fee why not set one directly in the FoxyCart admin and avoid the JavaScript hacks?
  • @luke — I only need the handling fee to be applied when someone is sending a gift card.
  • fc_adamfc_adam FoxyCart Team
    @troutoil, can you put the gift card in its own category? That way you can apply the handling fee to just the ones in that category.
  • troutoiltroutoil Member
    edited January 2011
    The gift card isn't a true product, it's never added to the cart — it's more like a gift-wrapping or gift-message option in that regard.

    Our fulfillment company charges per card though...

    It needs to be added at checkout like a gift message, which seems pretty tricky for a true product.

    I tried to replicate the gift-wrapping code posted elsewhere in the forum, but I just can't get the total to update. I can change the value of the variables in question (I've changed both orderShipping and orderFlatRateShipping), but they don't seem to change the total cost.

    I change those two variables with a function run before updatePrice and updatePriceDisplay (or is it updateTotal, I'm away from my machine right now) using the override function.

    -B
  • fc_adamfc_adam FoxyCart Team
    @troutoil, hacks can get pretty funky when it comes to live shipping, and also as you're using multiship. I'll have to take a closer look at whats going on for your checkout.

    Just to confirm, the handling fee is only added once to the total - not one for each multiship in the order?
  • No, it's added once for each multiship that is adding a card.

    Thanks for looking into that for me.

    -B
  • Ok. Man thank you guys so much.

    Adam found out the deal. It looks like this has always been the case, and no clients ever noticed.

    If you want to modify the shipping cost to 0, you must set the shipping cost in Foxycart to 0.

    Why? If you use javascript to modify the shipping cost, Foxycart only allows the shipping cost to go higher. If you try to make the shipping cost lower, the shipping looks right in the html and via console.log(FC.checkout.config.orderShipping), but when the person checks out, the shipping cost charged is the cost put into the Foxycart admin.
  • fc_adamfc_adam FoxyCart Team
    @troutoil,

    as your using multiship (and live shipping rates), its not quite as easy as just updating the orderFlatRateShipping value and be done with it. Ultimately you'll need to update the shipping for each multiship value. If you look through the checkout javascript, you'll see in updateShipping that if multship is active then it gets it's values from a whole different set of config values. I'd actually suggest for your setup that you take the following approach:

    Setup a click/change event on the checkboxes, that when selected you set the FC.checkout.config.multishipHandlingFees[multiship], where multiship is equal to the multiship number of that particular ship to order (it starts at 0), and then call the updateShipping function. This will refresh the shipping options for that ship to, and add on the handling fee to the shipping fee options. While this is still a hack, it makes use of default FoxyCart functionality a bit more than overriding the shipping price itself.

    Does that make sense?
  • troutoiltroutoil Member
    edited January 2011
    Thanks Adam, that definitely makes sense. Here's what I've come up with:
    function check_for_messages() {
    	
    	jQuery('.sendmessage').each(function() {
    		if (jQuery(this).attr('checked')) {
    			
    			//figure out the multiship from the name attribute of input.sendmessage
    			$multiship_array = jQuery(this).attr("name").split("_");
    			//assign that value to $multiship_name
    			$multiship_name = $multiship_array[2];
    			
    			//change handling fee for proper multishipHandlingFees[]
    			FC.checkout.config.multishipHandlingFees[$multiship_name] = (parseInt(FC.checkout.config.multishipHandlingFees[$multiship_name]) + .48);
    		}
    	});
    	//update the shipping
    	FC.checkout.updateShipping();
    } 
    
    


    and in (document).ready()

    // have .sendmessage checkboxes run check_for_messages
    	jQuery('.sendmessage').change(function() {
    		$(this).parent().next().slideToggle();
    		check_for_messages();
    	});
    

    That changes the values in the multishipHandlingFees array the way I hoped it too, but updateShipping doesn't seem to be refreshing the shipping cost. The S&H stay at the same rate even after changing that array and calling updateShipping.

    I tried calling updateShipping, updatePrice and updatePriceDisplay (in that order as well), but still no love.

    Again, thanks for your help and your time.
  • lukeluke FoxyCart Team
    I think I see the problem. FC.checkout.updateShipping() without any arguments won't work for multiship, you have to loop through all the multiship options you have and update each one like so:
    for (var i=0; i<config.multishipDetails.length; i++) {
    FC.checkout.updateShipping(i);
    }
    
    I _think_ that will work, but I'm not positive.
  • fc_adamfc_adam FoxyCart Team
    Oh sorry, yeah, you needed to do that per multiship. If that doesn't fix it, let us know and we can look into your code
  • That did it, here's what I wound up with for the final script.
    function check_for_messages() {
    	
    	jQuery('.sendmessage').each(function() {
    		
    		//figure out the multiship from the name attribute of input.sendmessage
    		$multiship_array = jQuery(this).attr("name").split("_");
    		//assign that value to $multiship_name
    		$multiship_name = $multiship_array[2];
    		
    		if (jQuery(this).attr('checked')) {
    			//change handling fee for proper multishipHandlingFees[]
    			FC.checkout.config.multishipHandlingFees[$multiship_name] = (parseInt(FC.checkout.config.multishipHandlingFees[$multiship_name]) + .48);
    		} else {
    			FC.checkout.config.multishipHandlingFees[$multiship_name] = 0;
    		}
    	});
    	//update the shipping
    	for (var i=0; i<FC.checkout.config.multishipDetails.length; i++) {
    		FC.checkout.updateShipping(i);
    	}
    }
    

    Thanks so much for all of your help!
  • fc_adamfc_adam FoxyCart Team
    edited January 2011
    Thanks for posting your code @troutoil, I've added this to http://wiki.foxycart.com/docs:advanced:forum
Sign In or Register to comment.