How to create an infinite loop

joelataylorjoelataylor Member
Hi there,

I'm writing a custom shipping method on v2. The goal is to get custom shipping pricing on some products (specific categories) and use FedEx pricing on other products (other categories).

I've been trying to call the FC shipping API: foxycart.com/v/2.0.0/api_json.php?ThisAction=GetShippingCost - but it's causing an infinite loop because it's referencing my custom shipping script again.

Any suggestions on how I could use FC shipping API and avoid the infinite loop? I really don't want to have to go create a FedEx dev account and go that route!!!

Thanks!!!
Tagged:
Comments
  • brettbrett FoxyCart Team
    Hey @joelataylor
    Interesting. We'll discuss this and see if we can shine any light on things.

    Are you saying that your custom endpoint is calling the api_json, to get the live rates from Foxy? If so… hrm… I wonder if you could pass an extra parameter through so your custom endpoint doesn't re-request api_json if it's not needed, thus ending the loop.

    (Fwiw, our next improvement to the shipping will be allowing a custom endpoint that gets passed the shipping rates as configured in the store. Not here yet though.)
  • Hey Brett - yeh, I figured what I was doing was a lil "hacky" - in that I'm curling FC to get live FedEx rates on products in a specific category. In fact, I don't think it's going to work (at least the way I'm doing it) because I don't know the fcsid outside of Javascript.

    My only solution now is to use a mix of the Custom Shipping method + Javascript overrides.

    Or, I go find my own connection to FedEx (which I REALLY don't want to do).

    You're "coming soon" feature sounds perfect for my use case. ;)
  • fc_adamfc_adam FoxyCart Team
    @joelataylor,

    Thanks for clarifying further. If I could ask another follow-up question, how would you handle the shipping costs if products from both categories are present? What rates are used then?
  • Hi @fc_adam - happy to help.

    We have the FC category setup for Flat Fee shipping at $0 for the products we have a custom calculation for. Our custom calculation takes into account the quantity ordered and the zip it's being shipped to.

    The other products have the FC Category setup for FedEx Live Shipping - that's how we're able to let FedEx only calculate the appropriate shipping rate.

    Make sense?
  • fc_adamfc_adam FoxyCart Team
    edited May 22
    @joelataylor - that does help, but I think it might be worth us seeing your store set up for better clarification here. Could you confirm (and feel free to whisper if you'd prefer to keep it private) the store you're working with and have the custom shipping script included on?
  • fc_adamfc_adam FoxyCart Team
    @joelataylor,

    Thanks for whispering. I think there is a way to achieve what you're after here without needing to do a custom integration with FedEx.

    To confirm with you about my earlier question - I understand that if you have only chairs, you calculate the shipping as a tiered flat rate, and if you have only accessories, then you use live FedEx results. If both are present though - could you clarify exactly what result you're after? Would it be just a single custom rate, with the total made up of the calculated custom rate, and then one of the returned live rates? If so - which live rate would you use? Or would you display all of the possible FedEx rates, but just increase them by the calculated rate?
Sign In or Register to comment.