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.

Shipping charges based on cart total


I'm attempting to use foxycart with Wix. I know exactly zero about code. Is there a way to write code that will ad a set fee based on the cart dollar total? in tiers, i.e,. $0 to $80.00 = $8.00, $81.01 to $215.00 = $10.00, $215.01 to $350.00 = $15.00, $350.01 to $500.00 = $27.00.

A tier fee system like this has worked best for our repeat product range.

Thank you for your response
  • fc_adamfc_adam FoxyCart Team

    Happy to help! For tiered shipping charges like that, you can use our custom shipping code functionality. The code for what you've described would look like this:
    const total_item_price = cart['_embedded']['fx:shipment']['total_item_price'];

    let shipping = 0;

    if (total_item_price <= 80) {
    shipping = 8;
    } else if (total_item_price <= 215) {
    shipping = 10;
    } else if (total_item_price <= 350) {
    shipping = 15;
    } else {
    shipping = 27;

    rates.add(10000, shipping, '', 'Standard Shipping');
    To add this to your store you can follow these steps:

    1. In the Foxy administration, head to the "shipping" section
    2. Ensure that all other shipping options are disabled, and enable the "use custom code" option. Paste the code shown above into the code editor that appears.
    3. Check the option to "enable shipping rate signing" and save the shipping page
    4. Wait 15-20 seconds and refresh the page to ensure the shipping has initialised successfully (you should see the code editor again if it has)
    5. Head to the "categories" section and for each category in your store, set the delivery type to "Shipped using live shipping rates". You'll also need to set a default weight for the categories, but you can set it to whatever you want.
    6. Optionally - if you don't want the "weight" attribute shown to customers, head to the "configuration" section, and within the "Customise cart display" option, uncheck the "Weight" option to hide that in the cart and save.

    At that point, if you load up your cart and enter a shipping address, you should see your shipping charges calculate according to the cart subtotal.

    Let us know if you have any questions about that, or if there's anything else we can help with.
  • OK, so bear with me here...I don't know f*ckall about code. If this is based on the full cart subtotal do i still need to add items to categories? How about leaving the categories at default for all of them? I conclude this possibility by your statement that the weight entry doesn't matter...and I presume you assume (Lol) that we have product categories already. we don't.
  • Also, I found this humorous...."Prior to launching FoxyCart we had months of discussions about shipping. One of the scenarios that we discussed was a mattress store. The mattress store may need to ship very large and heavy items, but also may need to ship pillows. They may also need to ship things via custom shipping carriers or freight options. In our early discussions, the afore-attributed anonymous lead developer said something like, “That's a ridiculous scenario. The average merchant won't have anywhere near the complexity in their shipping requirements.” The other person agreed, and FoxyCart development moved on."
  • fc_adamfc_adam FoxyCart Team

    Good question, the logic doesn't care about categories. I mentioned categories in my step just in case you were making use of multiple different categories, it would be important to update all of them to use live rates as a delivery method. If you're just using the default category, then you'll just need to ensure that one is updated to use live rates.
    Also, I found this humorous....
    :smiley: Glad you liked that haha
  • Updated for accuracy: Live rates needed a default weight.
  • OK...close. ..but it looks like a customer can skip the live shipping on the cart page and proceed to check out???
  • tbh I didn't follow it all the way through a test server...but it looks that way. Is there a way to make the step at the cart level a mandatory field? Or is it mandatory at the payment screen?
  • fc_adamfc_adam FoxyCart Team

    Good question. The shipping costs are not required on the cart, but they are required for the customer to be able to complete the checkout if there are live rate products present in the cart.
Sign In or Register to comment.