wojodesign / simplecart-js

A simple javascript shopping cart that easily integrates with your current website.
simplecartjs.org
1.79k stars 489 forks source link

Postage based on item weight? #364

Open franhaselden opened 11 years ago

franhaselden commented 11 years ago

Can anyone think of a way that postage could be calculated based on a weight attribute?

Example:

  1. I could somehow give every project an attribute of it's weight (100g for this, 400g for that).
  2. SimpleCart would add together the weight attributes of everything in the cart, so 500g
  3. Price brackets could be set up based on weights 100-200g = £x, 200-300g = £xx etc
  4. Postage number would be passed to PayPal.

Presently my postage rates are based on number of items.

My current postage setup.

Note on the below code, I have the spans for postage and giftwrap hidden unless there is 1 item in the cart. Postage rates are created based on adding £2 to the number of items in the cart, so:

1 item = £3 2 items = £4 3 items = £5

Seems to work quite well for me in terms of number of items, but as I'm selling heavier items I really need something better...

<script>
      simpleCart({
          shippingCustom: function () {
               $('.postage').show();
               $('.giftwrap').show();
                   if (simpleCart.quantity() == 0) {
                         $('.postage').hide();
                         $('.giftwrap').hide();
                   } else if (simpleCart.quantity() < 9) {
                           return (2 + simpleCart.quantity());
                   } else {
                         return 12;
                            }
                    }
              });
                </script>
tag666 commented 11 years ago

just what i need as well ! at the moment postage is worked out as a % of the total, which is not ideal.

  1. different weights for different items.
  2. combine and calculate on cart update.

please somebody help

franhaselden commented 11 years ago

Unfortunately I don't think anyone really cares about Simple Cart anymore. Shame, it was great. If anyone has a solution that does offer this kind of stuff, please let me know. I need to move away from SimpleCart as soon as I can.

Can anyone tell me how to unclose the issue? I didn't mean to.

tag666 commented 11 years ago

-__- ...but you closed the issue, so nobody will respond to help you, me or anybody else who has this problem now.

chekobil commented 11 years ago

I did this with the version 2, but changing the code in so many places that I don´t remember how I did. You can see it working here http://elquiltro.es/index_tienda.php the shop is in "la quiero section", (there´s an image taking so much time to load ...) click on the circles to add items an then click in "terminar compra", here you can see listed the total weight and his price. I don´t know how to send you the code from here, when I have time I want to make the same with the version 3.

tag666 commented 11 years ago

tbh I can't believe this feature wasn't in version 1.

@franhaselden thanks for a fast reopen :).

@feliper thanks for help, i'm new to javascript, i will figure it out one day, but that could be a while.