Jump to content

Customer can order 1,5 product


TomNetherlands

Recommended Posts

Good evening,

 

We have recently started our webshop with Cubecart which looks great!

But we faced an error which we cannot locate.

 

So for example, if the customer wants to order 1, 2, 3 etc products everything is fine.

But the moment a customer puts a figure behind the comma, so 1,5 or 2,5, Cubecart will

automatically reckon this in the total amount.

 

Can anyone help up us with this error? Is it just a feature we have to lock?

 

Thank you for the advise!

 

Kind regards,

Tom

Link to comment
Share on other sites

Welcome TomNetherlands! Glad to see you made it to the forums.

 

CC528 has a fix from an earlier version where the customer was able to input a fractional amount from the View Product page. The fix will round-down to the whole number.

 

However, there is still a bug(?) where the customer can update their cart during checkout with a fractional amount.

 

The fix (due in CC529) is:

In the file /classes/cart.class.php, find the function update(). About 26 lines into that function, change:

Was:
$this->basket['contents'][$hash]['quantity'] = $quantity;
Now:
$this->basket['contents'][$hash]['quantity'] = (int)$quantity; // or ceil($quantity);

 

But an aspect of seeing how CubeCart works is entering a comma as a whole/fractional separator (or decimal point). I don't know how CubeCart and/or PHP actually handles that.

 

Let us know if this solves your problem.

 

FYI: Early versions of CubeCart did not disallow fractional quantities, and some store owners sell products that are, in fact, sold by the fractional quantity. But Devellion has chosen to make CubeCart sell items by the whole-unit.

Link to comment
Share on other sites

FYI: Early versions of CubeCart did not disallow fractional quantities, and some store owners sell products that are, in fact, sold by the fractional quantity. But Devellion has chosen to make CubeCart sell items by the whole-unit.

This does not affect many stores, but for stores selling some types of items, for example material which is sold by the metre then it is a major issue. The only solution in standard CubeCart is to hold the stock in centimetres so a whole number is entered in the cart but then this looks odd to customers using the store as you would never purchase material as say 180 cm but would always order 1.80 metres.

To solve this problem for a client, we have just finished coding a plugin (doesn't affect any core CubeCart files !!) that provides a solution to this. In our example of a store selling material, stock would be held in centimetres with a price per centimetre, but everywhere on the front end of the store would show stock and pricing in metres or fractions of a metre. In fact it is possible to also define the Selling Multiple per product so one type of material could be sold in multiples of 25 centimtres and so when choosing a stock quantity to purchase, the quantity entry box changes to a dropdown selector with choices 0.25, 0.50, 0.75, 1.00 all the way up to the maximum available stock !!

We are just doing final testing of this but if anyone is interested in seeing a demo of it working or would like more information then please contact me directly

Thanks

Ian

Link to comment
Share on other sites

Welcome TomNetherlands! Glad to see you made it to the forums.

 

CC528 has a fix from an earlier version where the customer was able to input a fractional amount from the View Product page. The fix will round-down to the whole number.

 

However, there is still a bug(?) where the customer can update their cart during checkout with a fractional amount.

 

The fix (due in CC529) is:

In the file /classes/cart.class.php, find the function update(). About 26 lines into that function, change:

Was:
$this->basket['contents'][$hash]['quantity'] = $quantity;
Now:
$this->basket['contents'][$hash]['quantity'] = (int)$quantity; // or ceil($quantity);

But an aspect of seeing how CubeCart works is entering a comma as a whole/fractional separator (or decimal point). I don't know how CubeCart and/or PHP actually handles that.

 

Let us know if this solves your problem.

 

FYI: Early versions of CubeCart did not disallow fractional quantities, and some store owners sell products that are, in fact, sold by the fractional quantity. But Devellion has chosen to make CubeCart sell items by the whole-unit.

 

Good evening,

 

I am sorry couldn't find what you meant. We are using Cubecart 5.27, I don't know if this makes a huge difference?

Don't want to look silly, but we really just started and working our ways through, so I might have overlooked something....

 

Could you walk me through?

 

Thanks you for the quick response though!!

 

KR Tom van der Staak

Link to comment
Share on other sites

For the moment, I will assume you know how to use a programmer's text editor, and how to FTP (or otherwise access) to your site to fetch and place a file.

 

Fetch the file /classes/cart.class.php and open it for editing. The programmer's text editor will show line numbers -- scroll to line 1042.

 

Near here, you should find the statement:

public function update() {

Counting 26 lines after the above statement, you should find this statement:

$this->basket['contents'][$hash]['quantity'] = $quantity;

Please change this statement so that it reads:

$this->basket['contents'][$hash]['quantity'] = (int)$quantity;

The above edit will force any value entered as 'quantity' (such as 3,4) to its integer value (such as 3).

 

Alternatively, if you believe the customer should have the quantity be the next whole unit higher (such as 3,4 to 4), make the statement look like:

$this->basket['contents'][$hash]['quantity'] = ceil($quantity);

Then FTP the edited file back to your site.

Link to comment
Share on other sites

For the moment, I will assume you know how to use a programmer's text editor, and how to FTP (or otherwise access) to your site to fetch and place a file.

 

Fetch the file /classes/cart.class.php and open it for editing. The programmer's text editor will show line numbers -- scroll to line 1042.

 

Near here, you should find the statement:

public function update() {

Counting 26 lines after the above statement, you should find this statement:

$this->basket['contents'][$hash]['quantity'] = $quantity;

Please change this statement so that it reads:

$this->basket['contents'][$hash]['quantity'] = (int)$quantity;

The above edit will force any value entered as 'quantity' (such as 3,4) to its integer value (such as 3).

 

Alternatively, if you believe the customer should have the quantity be the next whole unit higher (such as 3,4 to 4), make the statement look like:

$this->basket['contents'][$hash]['quantity'] = ceil($quantity);

Then FTP the edited file back to your site.

 

Good evening (again :) )

 

We have been searching for this in FTP. But the file casses does not exist in our database. Don't know how that is possible?

 

So the line mentioned in your help lined above does not exist.

 

Do you know why?

 

KR Tom van der Staak

Link to comment
Share on other sites

From the information given to you by your hosting provider when you opened your account, there should be the username, password, and host needed to access with FTP to your site. You have been searching using FTP. So I will assume you are accessing your site correctly.

 

Generally, however, the initial folder you will be viewing is above the folder that holds your web site.

 

If you can find a folder named any of the following: doc_root, public_html, or website, this folder is where CubeCart should have been installed.

 

This folder should have the files index.php, admin.php, ini.inc.php, and others, and should have the folders admin, cache, classes, controllers, images, and others.

 

So, where Cubecart is installed, look in the folder "classes".

Link to comment
Share on other sites

@ bsmither:

On behalf of TOM, thanks for your replies.

But we have faced the following: There is no folder in public.html/cubecart/classes/ named cart.classes.php There only is a folder in public.html/cubecart/classes/ named cart.php

This document contains 3699 lines (comments included). This line: $this->basket['contents'][$hash]['quantity'] = $quantity; could not be found in this cart.php file.

We have surched all looking for the word basket, but the file doesn't contain it. So if we cannot find the line you have mentioned, it stays impossible to change it.

What's next?

 

Regards

Nollie

Link to comment
Share on other sites

Thanks man, but you've opened our eyes. After thourough examination we found out that php files got mixed up. The classes folder we were looking at belonged to an earlier webshop we tried by Prestashop. We have removed this application just now. And we now have found the proper php gile. We are going to look into it and hope that we are capable to implement the changes that you suggested. We will let you know how it went!!!

Thanks again.

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.

×
×
  • Create New...