# Shipping based on weight

**URL:** <https://forum.modmore.com/t/shipping-based-on-weight/357>\
**Category:** SimpleCart\
**Created:** [July 19, 2016, 10:25am UTC](https://forum.modmore.com/t/shipping-based-on-weight/357 "2016-07-19T10:25:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![christodhunter](https://forum.modmore.com/letter_avatar_proxy/v4/letter/c/dc4da7/32.png) [@christodhunter](https://forum.modmore.com/u/christodhunter)\
**Post date:** [July 19, 2016, 10:25am UTC](https://forum.modmore.com/t/shipping-based-on-weight/357/1 "2016-07-19T10:25:16Z")

</div>

Is it possible to calculate shipping based on the weight / quantity of products in the basket? Cheers!

---

<div class="post-metadata">

**Author:** ![mhamstra](https://forum.modmore.com/user_avatar/forum.modmore.com/mhamstra/32/459_2.png) [@mhamstra](https://forum.modmore.com/u/mhamstra)\
**Post date:** [July 19, 2016, 11:04am UTC](https://forum.modmore.com/t/shipping-based-on-weight/357/2 "2016-07-19T11:04:53Z")

</div>

Not cleanly in 2.4. It’s on the list to enable dynamic shipping costs based on weight or destination.

There’s a work around where you can use AJAX in the cart or checkout phase to hit up some custom code that calculates the price. That piece of code should create a new simpleCartMethod object with the shipping price, and return the ID of that method into the cart/checkout. Then back on the client-side adding that ID to a hidden input deliveryMethod will process it with the checkout.

---

<div class="post-metadata">

**Author:** ![christodhunter](https://forum.modmore.com/letter_avatar_proxy/v4/letter/c/dc4da7/32.png) [@christodhunter](https://forum.modmore.com/u/christodhunter)\
**Post date:** [July 19, 2016, 11:07am UTC](https://forum.modmore.com/t/shipping-based-on-weight/357/3 "2016-07-19T11:07:01Z")

</div>

That sounds cool. I was going to change the \_getDeliveryMethods function to look up the cart contents and output the correct delivery method. There are only three options based on price so the plan was to only output the one that related to the weight. Does that sound feasible or am I asking for trouble?

---

<div class="post-metadata">

**Author:** ![mhamstra](https://forum.modmore.com/user_avatar/forum.modmore.com/mhamstra/32/459_2.png) [@mhamstra](https://forum.modmore.com/u/mhamstra)\
**Post date:** [July 19, 2016, 11:09am UTC](https://forum.modmore.com/t/shipping-based-on-weight/357/4 "2016-07-19T11:09:06Z")

</div>

Changing core methods is definitely asking for trouble 😉

---

<div class="post-metadata">

**Author:** ![christodhunter](https://forum.modmore.com/letter_avatar_proxy/v4/letter/c/dc4da7/32.png) [@christodhunter](https://forum.modmore.com/u/christodhunter)\
**Post date:** [July 19, 2016, 11:11am UTC](https://forum.modmore.com/t/shipping-based-on-weight/357/5 "2016-07-19T11:11:11Z")

</div>

Do you have an example of the work around? Would another option be to have all methods available but hidden then use JS to show the one that relates to the weight of the cart?

---

<div class="post-metadata">

**Author:** ![mhamstra](https://forum.modmore.com/user_avatar/forum.modmore.com/mhamstra/32/459_2.png) [@mhamstra](https://forum.modmore.com/u/mhamstra)\
**Post date:** [July 19, 2016, 11:49am UTC](https://forum.modmore.com/t/shipping-based-on-weight/357/6 "2016-07-19T11:49:54Z")

</div>

Unfortunately no I don’t have an example for the workaround, though I do know people have used it.

A JS based approach might work as well, just want to make sure to also test it with javascript disabled so something server-side might be better 😉

---

<div class="post-metadata">

**Author:** ![christodhunter](https://forum.modmore.com/letter_avatar_proxy/v4/letter/c/dc4da7/32.png) [@christodhunter](https://forum.modmore.com/u/christodhunter)\
**Post date:** [July 19, 2016, 1:48pm UTC](https://forum.modmore.com/t/shipping-based-on-weight/357/7 "2016-07-19T13:48:34Z")

</div>

Sorted. Added weight to the product option then wrote a snippet to calculate the weight based on the items in the cart. Each delivery method has the weight as part of the name so used a conditional statement in the tpl to only add the applicable delivery method to the checkout. Job done. Thanks for the help Mark - glad I didn’t mess with the core code!
