Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Can multi orders of item create 1 line for each


HairyJim

Recommended Posts

Hi all,

 

Anyone know of a contib or code that will allow a new line item to be created rather than just increase the quantity to 2 or 3 etc....

 

Cheers

Jim

 

Do not understand the reason behind this but in checkout process you would have to change the line insert into a loop.

 

for x = 1 to item qty {

insert a line item with qty = 1

}

Treasurer MFC

Link to comment
Share on other sites

Do not understand the reason behind this but in checkout process you would have to change the line insert into a loop.

 

for x = 1 to item qty {

  insert a line item with qty = 1

}

 

Perhaps I was not clear enough.

 

When a customer clicks 'buy now' it adds an item to the shopping cart. If the customer wishes to purchase two of the same product then I wish it to create two line items in the cart rather than increase the quantity to 2.

 

The reason is that some of my items are upgrades to software and these upgrades have a license key attached to them which the customer must specify before purchasing. It is feasible to assume a customer may have two upgrades to purchase for the same software version therefore I wish the items to be listed twice so that two license keys are also specified by the customer.

 

I hope this makes more sense.

 

Jim

Link to comment
Share on other sites

Perhaps I was not clear enough.

 

When a customer clicks 'buy now' it adds an item to the shopping cart. If the customer wishes to purchase two of the same product then I wish it to create two line items in the cart rather than increase the quantity to 2.

 

The reason is that some of my items are upgrades to software and these upgrades have a license key attached to them which the customer must specify before purchasing. It is feasible to assume a customer may have two upgrades to purchase for the same software version therefore I wish the items to be listed twice so that two license keys are also specified by the customer.

 

I hope this makes more sense.

 

Jim

 

Yes, more sense but where and how do the users supply their license keys ?

Treasurer MFC

Link to comment
Share on other sites

Yes, more sense but where and how do the users supply their license keys ?

 

Firstly I created a license manager that is accessed from 'My account' very similar to the address manager.

 

I then installed the contribution called 'Imprint Text Options' that allows line items to have a text attribute attached to them. It was meant for people who sell items that can be personalised but I found it could be slightly modified and be used by myself. Quite simple to hook up with my license manager so that when someone orders a product they can pick the license from their manager file and attach it to the item.

 

So when a person navigates to a product that requires the inputting of their license a dropdown menu is available that looks at the license table and populates the list with any licenses they have stored in their account. They can then choose the license they wish to attach to the item, it is then just a simple click to add it to the cart.

 

The problem I encounter is the one I described earlier in that multiple quantities of the same item may be bought and therefore multiple licenses need to be defined unfortunatly when I add a second item of the same to the cart it just updates the quantities, I need it to create a new line.

Link to comment
Share on other sites

Firstly I created a license manager that is accessed from 'My account' very similar to the address manager.

 

I then installed the contribution called 'Imprint Text Options' that allows line items to have a text attribute attached to them. It was meant for people who sell items that can be personalised but I found it could be slightly modified and be used by myself. Quite simple to hook up with my license manager so that when someone orders a product they can pick the license from their manager file and attach it to the item.

 

So when a person navigates to a product that requires the inputting of their license a dropdown menu is available that looks at the license table and populates the list with any licenses they have stored in their account. They can then choose the license they wish to attach to the item, it is then just a simple click to add it to the cart.

 

The problem I encounter is the one I described earlier in that multiple quantities of the same item may be bought and therefore multiple licenses need to be defined unfortunatly when I add a second item of the same to the cart it just updates the quantities, I need it to create a new line.

 

ok, well, I have not tried this myself so I have not yet thought the implications "down the line" thru.

 

But you could look in the class shipping_cart.

There is this line of code when adding products:

 

if ($this->in_cart($products_id)) {

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

} else {

$this->contents[] = array($products_id);

$this->contents[$products_id] = array('qty' => $qty);

 

 

it means that if the item is already there, the qty is updated otherwise the item is inserted.

 

So you could eliminate that condition and always insert the item or if you would want that based on certain other conditions. change the condition.

Treasurer MFC

Link to comment
Share on other sites

ok, well, I have not tried this myself so I have not yet thought the implications "down the line" thru.

 

But you could look in the class shipping_cart.

There is this line of code when adding products:

 

      if ($this->in_cart($products_id)) {

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

      } else {

        $this->contents[] = array($products_id);

        $this->contents[$products_id] = array('qty' => $qty);

it means that if the item is already there, the qty is updated otherwise the item is inserted.

 

So you could eliminate that condition and always insert the item or if you would want that based on certain other conditions. change the condition.

 

Strange even with the code commented out it still increments the quantity!?

 

I will look further into ths on Monday morning.

 

Thanks!

Link to comment
Share on other sites

I am still struggling to work out a solution with this anyone got any further ideas?

 

I have tried modifying the shopping_cart.php class file and it either still adds 1 to the quantity or it willnot add anything at all.

 

A more experienced OsCommerce & PHP user got any insightful comments on this?

Link to comment
Share on other sites

Try writing the code for add_cart, with what you've uncommented, I have a customized version of osC so I don't have the stock shopping_cart.php

Insert clever remark here

Link to comment
Share on other sites

I am still struggling to work out a solution with this anyone got any further ideas?

 

I have tried modifying the shopping_cart.php class file and it either still adds 1 to the quantity or it willnot add anything at all.

 

A more experienced OsCommerce & PHP user got any insightful comments on this?

 

I think it is doing this because the products id is used as the key for the array.

So you will need to change the $contents array so it will allow for more than 1 of the same products id

Treasurer MFC

Link to comment
Share on other sites

I think it is doing this because the products id is used as the key for the array.

So you will need to change the $contents array so it will allow for more than 1 of the same products id

 

 

Sorry my PHP knowledge is not great, how do I do this or can you point me to info on where it is explained.

 

Thanks for your time and help.

 

Jim

Link to comment
Share on other sites

Sorry my PHP knowledge is not great, how do I do this or can you point me to info on where it is explained.

 

Thanks for your time and help.

 

Jim

 

you will have to create an independant index in the array like :

 

$this->contents[][$products_id] = array('qty' => $qty);

 

best site to read up on php arrays :

 

 

http://tw.php.net/types.array

Treasurer MFC

Link to comment
Share on other sites

you will have to create an independant index in the array like :

 

$this->contents[][$products_id] = array('qty' => $qty);

 

best site to read up on php arrays :

http://tw.php.net/types.array

 

 

whoooahhh - what was that flying over my head..... ;)

 

I'll have to do some reading and playing around but looks like this could be a hefty change if it is used elsewhere.

Link to comment
Share on other sites

whoooahhh - what was that flying over my head.....  ;)

 

I'll have to do some reading and playing around but looks like this could be a hefty change if it is used elsewhere.

 

well, this is one of the reasons why classes were invented, the big benefit is that the class takes care of its own data and everybody else simply asks the class for info.

 

That means that the internal datamanipulation remains internal and is not used and/or referenced elsewhere.

 

So chances are that the shopping_cat class is the only place you need to alter.

Treasurer MFC

Link to comment
Share on other sites

well, this is one of the reasons why classes were invented, the big benefit is that the class takes care of its own data and everybody else simply asks the class for info.

 

That means that the internal datamanipulation remains internal and is not used and/or referenced elsewhere.

 

So chances are that the shopping_cat class is the only place you need to alter.

 

Ok I am sorry I am lost with this.

 

So if I am right in my confusion then the array has an index which currently is being set as the product ID (lets say this is 10).

 

So

 

10 has a QTY value assigned to it. 10 => 1

 

When I add a new product to the cart it says does this product id exist if it does update the array value QTY therefore 10 => 2

 

So what I need to do is create a new index value so each product in the cart is identified uniquely.

 

So I would need an array structure that had a unique value which had two properties assigned to it QTY and Product_id.

 

I am slightly lost could you confirm this is what you mean?

Link to comment
Share on other sites

Hi all,

 

Sorry but i am still a little bemused by this.

 

I understand now that the shopping cart class indexes the array using the product id which is why even if I remove the call to the in_cart function it still updates the product quantity rather than add a new order line.

 

What I do not know how to do is to reindex this array so each line entry gets its own unique value. I do not know where to go from here.

 

Could someone please advise.

 

Regards

Jim

Link to comment
Share on other sites

Im really in need of some advice. I am struggling to get any further forward with something that is required for my store to go live.

 

Please any advice that can further elaborate on where I need to go from here would be mosty appreciated

Link to comment
Share on other sites

  • 7 months later...

I know it's a bit late in the game, but I've recently had to do something similar, where some products would be free, but you could buy extra, yet I needed it to be on different lines. What I did was look at at attrib system, as that can have multiple lines for the product, I created an extra ATTRIB option, then edited the class and application top where it adds to the cart. This was the only way I knew how without totally changing the way osC does it.

Insert clever remark here

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...