Answers.Body: <p>You could build a plugin that listens to <a href="https://craftcommerce.com/docs/events-reference#commerce_cart.onbeforeaddtocart" rel="nofollow noreferrer">https://craftcommerce.com/docs/events-reference#commerce_cart.onbeforeaddtocart</a> and translates the front end values of 10.5 or 10'6" or whatever into the number of inches (or, if you're working in a sane part of the world, even cm!).</p>
  
  <p>Then on display of the cart or updates etc, you'll want to use some JS and/or twig maths to translate that back into those crazy feet/inch units you need there.</p>
  
  <p>I honestly think trying to retro-fit in partial unit sales into Commerce as a whole would be quite a considerable challenge, so I think the best way to solve this is to use your smallest unit as the back end unit of quantity for the product, and do the magic in your plugin/and display.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-09T14:45:17.687Z
Answers.Text: You are the second one to present this solution, thank you! The biggest problem is getting the client the change all their pricing to reflect the smallest unit of measure. Was hoping I could change the database or extend the LineItem Model to do this but can't find any good docs on that.
Answers.UserDisplayName: Richard Gil
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-09T23:58:40.187Z
Answers.Text: Well if you're not going down the above path, a custom purchasable would be the way to go I guess.  That will involve digging in to the Purchasable interface and fair bit more work....
Answers.UserDisplayName: Jeremy Daalder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-10T15:36:31.367Z
Answers.Text: Are there any good resources for writing a custom purchasable? I haven't been able to find anything. I am a generalist, so I can muck my way through it but need a good starting point. Thanks for all the replies, appreciate it.
Answers.UserDisplayName: Richard Gil
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-10T23:19:20.363Z
Answers.Text: Other than this? https://craftcommerce.com/docs/purchasables - that should be enough to get going (with some Luke help on Slack added ;) ) - but personally I would solve it the other way.
Answers.UserDisplayName: Jeremy Daalder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-08T23:47:54.423Z
Answers.LastActivityDate: 2017-08-08T23:47:54.423Z
Answers.UserDisplayName: Jeremy Daalder
Body: <p>I need to accept a decimal value for the quantity of a line item and for the total quantity. I understand this is not a normal request for most products but my client sells items by the foot and needs the flexibility to sell lengths in feet and inches (ex. 10 ft. 6 in. = 10.5 or 5 ft 6.5 in. = 5.541. I could probably hack this using JavaScript on the front-end but would like to do this the correct way. Any guidance is greatly appreciated. Has anyone achieved this?</p>
  
Tags: <plugin-craftcommerce>
Title: Decimal value for quantity
ThreadText: # Decimal value for quantity
  
  (Asked by: username_0 on 2017-08-08)
  
  I need to accept a decimal value for the quantity of a line item and for the total quantity. I understand this is not a normal request for most products but my client sells items by the foot and needs the flexibility to sell lengths in feet and inches (ex. 10 ft. 6 in. = 10.5 or 5 ft 6.5 in. = 5.541. I could probably hack this using JavaScript on the front-end but would like to do this the correct way. Any guidance is greatly appreciated. Has anyone achieved this?
  
  **Tags:** plugin-craftcommerce
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-08-08. Score: 2 | Accepted answer
  
  You could build a plugin that listens to <https://craftcommerce.com/docs/events-reference#commerce_cart.onbeforeaddtocart> and translates the front end values of 10.5 or 10'6" or whatever into the number of inches (or, if you're working in a sane part of the world, even cm!).
  
  Then on display of the cart or updates etc, you'll want to use some JS and/or twig maths to translate that back into those crazy feet/inch units you need there.
  
  I honestly think trying to retro-fit in partial unit sales into Commerce as a whole would be quite a considerable challenge, so I think the best way to solve this is to use your smallest unit as the back end unit of quantity for the product, and do the magic in your plugin/and display.
  
  > **Comments:**
  > **username_0**: You are the second one to present this solution, thank you! The biggest problem is getting the client the change all their pricing to reflect the smallest unit of measure. Was hoping I could change the database or extend the LineItem Model to do this but can't find any good docs on that.  
  > **username_1**: Well if you're not going down the above path, a custom purchasable would be the way to go I guess.  That will involve digging in to the Purchasable interface and fair bit more work....  
  > **username_0**: Are there any good resources for writing a custom purchasable? I haven't been able to find anything. I am a generalist, so I can muck my way through it but need a good starting point. Thanks for all the replies, appreciate it.  
  > **username_1**: Other than this? https://craftcommerce.com/docs/purchasables - that should be enough to get going (with some Luke help on Slack added ;) ) - but personally I would solve it the other way.  
  
  ---
  
  