I'm trying out the Craft Commerce plugin, and i'd like be able to let users order products with a custom price based on a choosen weight.

The price is now fixed to what you choose in the control panel, and there seems to be no easy way around that, but perhaps i'm wrong.

Is this possible? It's pretty crucial feature i need, so any help is appreciated :)

Cheers, Bob

  • Can you flesh the question out a little more Bob - is the price a fixed cost per weight unit (in which case Steve's solution below should work well)? Or is it more complex than that? A simple plugin could do more complex thing by listening to craftcommerce.com/docs/… for example.. May 24 '16 at 22:55
  • Hi Jeremy, thanks. The price is a fixed cost per weight, but as far as i can check that info, getWeightRate(), is only available in a cart and not through a product model? But perhaps i'm wrong there. May 30 '16 at 9:37

1oz = $1 ∴ 10oz = $10

Sell in units of weight as the quantity of the item.

  • Hi Steve, thanks. That seems to be a way to go about it, i'm going to check it out. May 30 '16 at 9:44

UPDATE: A new onPopulateLineItem event was added to Craft Commerce to enable this exact use case of modifying an items price when added to a users basket. You could use it to get the items weight and multiply it by a value.

I'm not sure what kind of product model you have to want to do this but a possible solution you might want to look at is charging shipping rates based on a products weight.

You can set up a Shipping Method with a rule that uses the weight of an item multiplied by a Weight Rate.

  • Hi Luke, thanks. I checked out the getWeightRate(),am i right that this is only available through a cart and not through a product model (or as individual 'shipping' model). I need to be able to use it in a product page to show the buyer a eventual price before actually ordering it.. May 30 '16 at 9:40
  • Updated original answer to include information about a new event that could help you. Jun 13 '16 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.