Jump to content



Photo
- - - - -

All sites have this bug, so heres the fix


This topic has been archived. This means that you cannot reply to this topic.
54 replies to this topic

#41   helply

helply
  • Members
  • 53 posts

Posted 23 August 2004 - 11:42

wow this is a great thread with all the neat ways to do things with the cart maybe you all can help me, any ideas on how to stop "0" quantity from adding the product to the cart. If the product is not already in the cart and i put in "0" for the qty, it gets added. If already in the cart, adding "0" appears to do nothing. This is driving me crazy, is anyone else having this issue/feature problem. I need to figure out why it is adding a "0" quantity product to the cart from the product listing pages. thanks

#42   koie

koie
  • Members
  • 113 posts

Posted 23 August 2004 - 15:43

I have been following this thread and found it very usefull. The Shop I maintain sells fabric by the meter. It works if someone buys 1.5 meter but it doesn't accept less than 1 meter. (EG 0.2 meters)
It then says the cart is empty.
This must be something easy but I can't seem to find it. Anyone some clues?

Thanx,

Remko

#43   koie

koie
  • Members
  • 113 posts

Posted 09 October 2004 - 08:08

My shop sells fabrics aan needs to sell parts of a meter. (eg. 1.5 meter)

To accomplish this I changed 2 database tables.

The first table

orders_products

I changed the field products_quantity from INT to Decimal (15,3)

The second table

customers_basket

I also changed the field customers_basket_quantity from INT to Decimal (15,3)


This second table is when users are not logged in yet and add products to there cart.

If you need this I recommend to backup your database first. I am just an amateur in this so I might have overlooked something.

Remko

#44   eetwiz

eetwiz
  • Members
  • 12 posts

Posted 21 November 2004 - 14:10

I actually modified the update_quantity() method in the shoppingCart class to convert the $quantity to an int before processing. 

$quantity = (int)$quantity;

<{POST_SNAPBACK}>



Where exactly did you modify this? And what did you enter?

   function update_quantity($products_id, $quantity = '', $attributes = '') {
      global $customer_id;

      if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true..

      $this->contents[$products_id] = array('qty' => $quantity);
// update database
      if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

      if (is_array($attributes)) {
        reset($attributes);
        while (list($option, $value) = each($attributes)) {
          $this->contents[$products_id]['attributes'][$option] = $value;
// update database
          if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'");
        }
      }
    }

// define the project version

 define('PROJECT_VERSION', 'osCommerce 2.2-MS2');

#45   tulx

tulx
  • Members
  • 4 posts

Posted 24 November 2004 - 07:00

Hi folks out there, reading all these postings ... I've done it today and tried a few things, but, how sad, it didn't make any fancy impression what so ever!

To give some support to one posting, I would also suggest, if some of you bright guys (f/m) out there would just add a configuration click in the admin tool. This way, a lot of time could be saved and almost everyone made happy at once. People like me don't really fancy implementing or changing codes. Testing and reporting is fine, but if changes could be handled the easy way, that would improve this fabulous tool even faster.

I stop here and just enjoy the times, when customers think they want to order 1.5 Bonsai Pot from my store to be - think positive: it improves communication or customer relationship and that's the beginning of suggess anyway.

Best Regards,

tulx

#46   jcall

jcall
  • Members
  • 3,093 posts

Posted 26 November 2004 - 04:02

Gerhard - - since it's more work to add configuration items into the Admin area, if you're making a tweak that you won't be turning on/off much, it is less work to just make the code change.

A central strength of osCommerce is that it's open-source. That means that anyone can change it in any way that they want. It's not reasonable to expect all of those changes to be nice, pretty, or to work for everyone. The changes often do just what the author wanted them to do, and need a little editing for general consumption.

Since you say that you "don't really fancy implementing or changing codes (sic)", then I suggest that you either:
1) avoid customization as much as possible
2) start learning to make code changes
3) hire someone who is more comfortable making code changes
4) purchase an alternate shopping cart

I don't mean to be rude, but if you want customization, you can't really expect it to take place on its own. Someone has to do it. That someone will have to make code changes.

-jared

#47   Recidivist

Recidivist
  • Members
  • 71 posts

Posted 28 November 2004 - 11:47

Where exactly did you modify this?  And what did you enter?

<{POST_SNAPBACK}>


Mooretis gave a really great tip which simplifies this greatly.

Using his idea in shopping_cart.php (in /includes/classes/) i changed:

$this->update_quantity($products_id, $qty, $attributes);

to:

$this->update_quantity($products_id, $qty = (int)$qty, $attributes);

This works great for me. Of course, it does round down any fractional quantity entered. i.e. 1.1 becomes 1, 1.5 becomes 1 and 1.9 becomes 1.

Hope this helps someone.

KB
Network Webcams - The IP Camera Specialists

#48   woosah

woosah
  • Members
  • 29 posts

Posted 08 December 2004 - 07:41

Yes, this last option was the easiest and worked lika a charm!
Thanks alot, i really needed this for my shop, it ain't easy shipping a half golf club /biggrin.gif' class='bbc_emoticon' alt=':D' />

#49   anchor555

anchor555
  • Members
  • 2 posts

Posted 24 November 2005 - 10:21

My shop sells fabrics aan needs to sell parts of a meter. (eg. 1.5 meter)

To accomplish this I changed 2 database tables.

The first table

orders_products

I changed the field products_quantity from INT to Decimal (15,3)

The second table

customers_basket

I also changed the field customers_basket_quantity from INT to Decimal (15,3)
This second table is when users are not logged in yet and add products to there cart.

If you need this I recommend to backup your database first. I am just an amateur in this so I might have overlooked something.

Remko


Hello, Your suggestion was very helpful. I also changed 2 fields in the products table. The 2 fields are:

products_quantity
products_ordered

This will help track those fractions in your inventory and sales totals.

One other change I had to make was in includes/classes/shopping_cart.php

There is a function called: "function add_cart" around line 91.

Below it you'll find the code: $this->update_quantity($products_id, (int)$qty, $attributes);

If you need fractions this line should read: $this->update_quantity($products_id, $qty, $attributes);

I removed the (int) since I need the decimal feature for a fabric store. That got decimals working correctly for our store.

Jim

Edited by anchor555, 24 November 2005 - 10:25.


#50   DubZ28

DubZ28
  • Members
  • 407 posts

Posted 17 March 2006 - 17:27

I think this is a problem that doesn't need addressing. It may be true that someone COULD order 2.5 shirts, but WHY would they? What are they expecting to get as .5 of a shirt. However, if you change the fuctionality of the store it limits you when you start selling a product that can be broken into parts. 1.5 lbs of gumballs, or 2.6 feet of wire.

Real problems are problems that actually cause issues. In this case, your time and resources are better spent elsewhere.
"You don't need to speak to say something."

#51   jervin

jervin
  • Members
  • 7 posts

Posted 30 April 2009 - 12:36

For me its necesary to add decimal products in cart!!!
I want to ad from same product once for example 1.7 and once 7.6 there is a porblem its get 9.3 smile.gif
Is there a solution for that to dont sum the quantity?

#52   deannadawn

deannadawn
  • Members
  • 3 posts

Posted 29 February 2012 - 17:16

I am having the opposite problem now. I am changing my quilting store shopping cart from magento to oscommerce and having such a difficult time figuring out how to allow customers to purchase decimal values of products for example like .25 or .50 or 2.5 etc.... Can someone lead me in the right direction? I am using oscommer 2.3.1. Thanks Deanna

#53   Jack_mcs

Jack_mcs
  • Members
  • 26,567 posts

Posted 29 February 2012 - 19:43

I am having the opposite problem now. I am changing my quilting store shopping cart from magento to oscommerce and having such a difficult time figuring out how to allow customers to purchase decimal values of products for example like .25 or .50 or 2.5 etc.... Can someone lead me in the right direction? I am using oscommer 2.3.1. Thanks Deanna

I'm not sure I understand what you are asking. What is a decimal value of a product? Do you mean that if you sold rope you would want customers to buy it by the foot, or something like that?

#54   Juto

Juto
  • Members
  • 369 posts

Posted 29 February 2012 - 19:59

Hi, the best way to do it is to use ajax attributes. First, set attributes to 0.25, 0.5...etc. Then, when you add a product to your catalog you can increase / decrease cost for each of these attributes.

Sara

#55   Juto

Juto
  • Members
  • 369 posts

Posted 29 February 2012 - 20:02

Further to this: In English speaking countries the decimal delimeter is the dot, while in other countries it's the comma.
In conclusion this is a dilemma, which can be fixed dependent on shipping zones.