Add fields to $_SESSION['cart']

Open to all! Ask other shopowners for help.
Post Reply
LeeFoster
Contributor
Posts: 263
Joined: Sun Feb 28, 2021 9:41 pm
Phoenix Version: v1.0.8.20
Has thanked: 1 time
Been thanked: 5 times

Add fields to $_SESSION['cart']

Post by LeeFoster »

Hi,

I am trying to create a text input pi module. Some of the products we sell allow or require text input.

I have created a text input box but am stumped on the next step, adding it to the cart session and then in to the customers_basket table.

Does anyone have experience of doing this? I would prefer to use hooks as opposed to hard coding.

Any help is much appreciated.

Tags:


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Add fields to $_SESSION['cart']

Post by ecartz »

For what you are doing, you might be better off doing things in some different fashion. Note that the original Option Type Feature modified the tables to store a string instead of a number. The contents array is accessible from outside the shopping cart. So you could override the necessary actions and modify the array directly.

I could add new hooks to the action processing. That would save having to override the action file. But it probably won't get released until at least November.
LeeFoster
Contributor
Posts: 263
Joined: Sun Feb 28, 2021 9:41 pm
Phoenix Version: v1.0.8.20
Has thanked: 1 time
Been thanked: 5 times

Re: Add fields to $_SESSION['cart']

Post by LeeFoster »

ecartz wrote: Tue Sep 07, 2021 12:11 am So you could override the necessary actions and modify the array directly.
Could you point me in the direction of which file/s to modify?
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Add fields to $_SESSION['cart']

Post by ecartz »

includes/actions/add_product.php might be the only action that works with attributes.
LeeFoster
Contributor
Posts: 263
Joined: Sun Feb 28, 2021 9:41 pm
Phoenix Version: v1.0.8.20
Has thanked: 1 time
Been thanked: 5 times

Re: Add fields to $_SESSION['cart']

Post by LeeFoster »

ecartz wrote: Tue Sep 07, 2021 1:00 am includes/actions/add_product.php might be the only action that works with attributes.
I'm not adding it as an attribute, it's a stand alone field.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply