Jump to content

Quantity other than whole number


Guest Christine from gecko Gully
 Share

Recommended Posts

Guest Christine from gecko Gully

I was trying to help a client who sells fabric by the metre, and who wanted to be able to sell, say, 1.25 metres (one and a quarter metres).

I looked in all the forums, and found some others who had asked for help with this, but nobody had come up with an answer.

So I have solved it myself, and this is as good a place as any to document what I did! (Also a good place for me to find it again if I need to do it for another client later - vbg).

Note that I made these changes on a site that is not yet live, so I don't care what happens to any "old" orders. I don't know what would be the effect of doing the database change on a live database.

There are three files that need to be changed, and one change to the database. Make sure you back EVERYTHING up before you start, and test it after!!

First the database change. You need to go into the CubeCart_order_inv table and change the definition of the field "quantity" from INT(32) to DECIMAL(32,2). That will allow it to store numbers with up to two decimal places. If you need more decimal places than that, make the second number (the one after the comma) greater.

Then you need to change the program includes/boxes/shoppingCart.inc.php . Find this code:

		$quantity = ceil($_POST['quan']);

and change it to this:

		$quantity = $_POST['quan'];

Then change the program classes/cart.php . Find this code:

		$quantity = ceil($quantity);

and get rid of it, or comment it out:

//		$quantity = ceil($quantity);

Save and upload the two programs.

That's it!

I hope this helps someone.

Christine Abela

Gecko Gully

www.geckogully.com/websites

Link to comment
Share on other sites

  • 4 weeks later...

Guest estelle

Well done Christina :)

If you or anyone wants to allow fractional quantities, i.e. quantities entered as a whole number followed by a fraction, please contact me as I have just developed a custom mod for a client. I have developed it for CubeCart 4 but I could make it work with CubeCart 3.

For example, the customer could enter 3 and then select 1/8 from the drop down list. The customer does not need to calculate the floating point value at any point in time, in the view product page and also in the checkout pages they can enter the integer number and select the fractional part. The store administrator would choose which products can have fractional quantities within the Admin -> View Products area.

If anyone needs this functionality for a store, please contact me.

Link to comment
Share on other sites

Guest Christine from gecko Gully

Good one Estelle! (All hail O Queen of the Modders!!)

I thought about putting in options to add to the quantity like adding 1/4, 1/2 and 3/4, etc. But it wouldn't work if the total quantity was less than 1.

In other words, I could add a half a metre of fabric using an option, but only if I had already entered a quantity greater than zero in the quantity box.

Will your mod allow zero in the quantity box, then add the partial amount?

Most of my clients sell stuff for quilters, who like to buy small quantities of fabrics.

Christine.

Link to comment
Share on other sites

  • 1 month later...
Guest estelle

Good one Estelle! (All hail O Queen of the Modders!!)

I thought about putting in options to add to the quantity like adding 1/4, 1/2 and 3/4, etc. But it wouldn't work if the total quantity was less than 1.

In other words, I could add a half a metre of fabric using an option, but only if I had already entered a quantity greater than zero in the quantity box.

Will your mod allow zero in the quantity box, then add the partial amount?

Most of my clients sell stuff for quilters, who like to buy small quantities of fabrics.

Christine.

I will release this as a mod but not sure when I will have the time... If you like you could contact me in January to follow up on this, I hope to be able to release it in January.

Link to comment
Share on other sites

  • 4 weeks later...

Thanks for the info - do you know if this can be done the same way with CC4?

I like the idea of the mod too Estelle - will it be for CC4 too?

This was something I had wanted to do with my store when I was first setting it up. I've worked around not being able to, but I might make a change now.

I do have a question for you both though....

First, how does using the decimal value affect inventory control? Will it still keep track of the inventory and deduct the purchases appropriately?

Estelle.... I am using your Quantity discount mod so that the buyer will get the fabric a little cheaper when they purchase 4 fat quarters(1 yard) versus buying it just by the Fat Quarter. Would I still be able to use that mod with this mod you mention?

Thanks for your help.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...