Date: 12/10/99
- Next message: Samuel Liddicott: "RE: [PHPLIB] Warning - Same session in two browsers?"
- Previous message: Roman Kalenjuk: "Re: [PHPLIB] auth_validatelogin()"
- In reply to: Martin Decker: "[PHPLIB] cart questions"
- Next in thread: Bob Bowker: "Re: [PHPLIB] cart questions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello Martin,
Cart.inc reads like this:
Line 16: var $item = array(); ## The shopping cart array($item,
array("art"=>..., "num"=>..., ...))
Thus I believe that the cart-container holds an item-id keyed to an
array of properties.
All you have to do is modify the add_item() function.
The lines below are intended to show the "theory", I just wrote them
down, please correct me if I did syntax errors,
or misunderstood cart.inc.
-------------------Snip---------------------------
function add_item($art, $num) {
## Check to see if we already have some of these
list($item, $have) = $this->check($art);
## We already have them
if ($item) {
$this->item[$item]["num"] += $num;
return $item;
}
## New article
$item = $this->currentItem++;
$this->item[$item]["art"] = $art;
$this->item[$item]["num"] = $num;
## THIS IS NEW STUFF FOR ADDITIONAL ITEM PROPERTIES....
$color = "red"; // you could fill this value from a query...
$stock = 2; // You could fill this value from another query....
$this->item[$item]["color"] = $color; // this put the add.
properties with the item in the cart.
$this->item[$item]["stock"] = $stock; // slowly you are getting to
it... ;-)
return $item;
}
-------------/Snip-----------------
Cheers,
Andre
-----------------------------------------
> Hello everybody,
>
> Unfortunately, nobody could answer my question of how to extend the cart to
> hold additional attributes.
> I need to modify cart.inc, because I have an additional field called
> "stock". When the user buys 5 pieces
> of product 1 from stock1 and 2 pieces from stock2, the orders are not
> allowed to be summed up! There
> have to be two seperate entries in the cart.
>
> How can I do that?
>
> I would greatly appreciate any help!
>
> Thanks in advance,
>
> Martin
>
> *****************************************
> Martin Decker, martin.decker <email protected>
> Telekommunikationstechnik und -systeme
> Fachhochschule Salzburg
> Jakob-Haringer-Str. 1a/II/12
> Tel. 0664 5775697
>
> -
> PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
> To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
> the body, not the subject, of your message.
-
PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
the body, not the subject, of your message.
- Next message: Samuel Liddicott: "RE: [PHPLIB] Warning - Same session in two browsers?"
- Previous message: Roman Kalenjuk: "Re: [PHPLIB] auth_validatelogin()"
- In reply to: Martin Decker: "[PHPLIB] cart questions"
- Next in thread: Bob Bowker: "Re: [PHPLIB] cart questions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

