Shipping Complications

rcatesrcates Member
in Help edited January 2014
Hi Foxy Cart,

I hope you all had a wonderful new year! Happy 2014 :)

Moving on, here is my situation:

My client has expressed to me that keeping his margin tight on shipping costs is crucial to the success of his store. That said, he has a rather complicated setup for packaging. He has 3 different weights of products, 4 different weighted/sized containers, a varying number of gel packs required to keep products cool during shipment that add weight, as well as the possibility to have full, or partially full containers, further varying the weight.

He has no desire to use any of the shipping options presented in the admin menu. So, it seems to me like I need to calculate the weight beforehand, to be live estimated through the Fed Ex live rate functionality. But, when thinking about how that will work, your estimator takes the weight of a given singular product and multiplies that weight by the quantity, and then combining the price of individual products. Am I correct in my thinking?

Is there any chance I can work out a way to do maths, and pass a single weight to the Fed Ex live rate plugin? If not, how do you suggest I do this? I'm starting to worry it may not be possible with how things are set up currently. I hope I am missing something rudimentary!

Comments
  • fc_adamfc_adam FoxyCart Team
    @rcates,

    I'm a little confused about what you want to achieve exactly, so I'll give you a quick overview of what our system does out of the box.

    We send a request off to the relevant shipping providers based on the rates you select in the admin, passing along the address details of the store and the customer, as well as the total weight of the order for all products included in the cart. We don't currently allow for setting the size of the shipping container, or specifying multiple packages, but rather just a single package at the weight of the products.

    I'm not sure if that helps at all - could you give me an overview of exactly what your client is wanting to do? Are you wanting to connect to a different shipping endpoint for FedEx than the one we're integrated with currently?
  • rcatesrcates Member
    edited January 2014
    Sorry for the confusing post!

    I'll try to keep it simple. I think not fully understanding how this is going to be solved is making it harder to explain.

    How hard is it to run a script when a user deletes a product from the cart, or changes quantities of products from the cart? I would need to modify the weight because packaging could change drastically (thus, weight would too).

  • fc_adamfc_adam FoxyCart Team
    @rcates,

    It really depends where exactly you're doing the calculations. If you're doing it on the checkout, then you can just do it on pageload there, as nothing would change there without the page being reloaded.

    For the cart, you should be fine to do it on page load there as well. Adding a product, changing a quantity or removing a product all trigger a page load.

    The checkout would probably be the most reliable place, depending on what you're doing of course.
  • Agreed, checkout would be most reliable. I wasn't aware I could do anything on the checkout page.

    How does that work? My first guess would be to add the script to the checkout template. Is there any documentation that could help straighten me out?
  • fc_adamfc_adam FoxyCart Team
    @rcates,

    No documentation unfortunately. Making third-party calls is definitely possible on the checkout, but you'd also need to make sure that the endpoint you're contact is secured over HTTPS - otherwise the communication will be blocked by the browser.

    That said though, if you're using our native shipping functionality, and just want to alter the the total weight of the cart, you can do that pretty simply on the checkout too - it would just be a script that runs on page load to calculate your changes and then apply it to the javascript config value for the total weight. You can find that value by searching the source of your checkout page.
  • Okay, the onload script call makes sense. By third-party call, do you mean including a script in the template that is located on say, my server? If so, it seems as though including the whole script inline in my template would be optimal?
  • fc_adamfc_adam FoxyCart Team
    @rcates,

    Yeah, by third-party I was referring to a script (like a PHP script) that you make a request to from the checkout that exists somewhere else like on your server. If you're just working with javascript, then having that whole script inline on the checkout template is definitely your best choice.
  • Thank you so much Adam! You're awesome :D
  • I'm having trouble locating this weight variable.

    I've been looking in fc_shipping_container, down through everything. Haven't found a weight there. I have found the shipping cost etc.

    Then, I've been looking in the cart table as well. This seemed pretty promising, however, there isn't a total weight. In fc_cart_item_weight, I do see a weight=1.5, but that seems like something that is incorporated into maths with quantity.

    Furthermore, fc_form_checkout_error gives me: Some required information is missing.

    I'm trying my best to piece this together on my own, but I'm having no success thus far.
  • rcatesrcates Member
    edited January 2014
    Okay, so I kept on digging, and found some JSON in a script in the page's head. I'm seeing 'Weight: 4.5' which is correct for the quantity of products I have in the cart currently. I may be all set. I'll post with updates.
  • Mozilla's Developer Network and Stack Overflow taught me the JavaScript/JSON I needed to get this working. Rubber duck debugging here helped also.

    The fc_json object located in the head of the checkout page was in fact the answer. It provides everything I need to obtain accurate shipping costs for my client's customers.

    Solved.
  • fc_adamfc_adam FoxyCart Team
    @rcates,

    Sorry - I should have been more specific. Search the checkout source code for "FC.checkout.config" and you'll see the big config object with a heap of different variables. If you're using live rates and not multiship based, the on you'll want is:
    FC.checkout.config.orderLiveRateShipmentWeight
    
  • rcatesrcates Member
    edited January 2014
    Well this is embarrassing... Thank you for sorting me out though! I still need the JSON object to add in package/gelpack weights and do maths. It's making that process rather convenient. I'll look for that variable, we're using live rates.
  • fc_adamfc_adam FoxyCart Team
    @rcates,

    Yeah - the cart JSON object will definitely be your best bet for running through what products are present in the cart
Sign In or Register to comment.