Check one or many attributes option

Open to all! Ask other shopowners for help.
Post Reply
m0fix
Member
Posts: 7
Joined: Mon Nov 13, 2023 12:59 pm
Phoenix Version:

Check one or many attributes option

Post by m0fix »

Hi,

[phoenix]
version = 1.0.8.20
[mysql]
version = 10.6.12-MariaDB-0ubuntu0.22.04.1
[php]
version = 8.0.30

I Will be gratful if someone gives me hints on how to get cart sessions with a list of attributes
i tryed to return an array in pi_options_attributes.php but it's not working:

Code: Select all

'selection' => is_string($_GET['products_id'])
                       ? $_SESSION['cart']->contents[$_GET['products_id']]['attributes'][$option_id] ?? []
                       : [],
and have checkbox toogle btns in template:
Screenshot from 2023-11-19 17-29-39.png

thanks
You do not have the required permissions to view the files attached to this post.


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
Kofod95
Senior Contributor
Posts: 749
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Check one or many attributes option

Post by Kofod95 »

Forgive me if I misunderstand, but do you want people to be able to select multiple values for the same option (like ananas and olives in your screenshot)?

The system is not set-up for that, as that would also allow them to choose both S and L for the same product in your screenshot.
To allow multiple attributes, you either need to add more groups (supplements 1, supplements 2 etc) or code a new add-on for it. -At least as far as I know..

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
m0fix
Member
Posts: 7
Joined: Mon Nov 13, 2023 12:59 pm
Phoenix Version:

Re: Check one or many attributes option

Post by m0fix »

So options1 Size will be radio toogle btns and options2 supplements as a checkbox toogle btn but yes i'm coding an addons something like this one:
app.php/addons/paid_addon/display_optio ... pi_module/

i'm blocked once we have L size, ananas and olives for exemple checked i want to pass those attributes values to $_SESSION['cart']; simply update the cart.

any suggestions?
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Check one or many attributes option

Post by heatherbell »

m0fix wrote: Sun Nov 19, 2023 10:56 pm any suggestions?
Keep it simple by making an Option for each Supplement and making "No thanks" and "Yes please" as Attributes for each Option.
You could also then extend the Attributes to allow "Double" portions of a Supplement, so for example, make "No thanks", "Single Portion" and "Double Portion" as Attributes which could also then increase the sale price per order.
This now makes me hungry for pizza!
🍕 I'll have mine with Double Kefta and Double Salami please! 🍕
raiwa
Certified Developer
Posts: 1641
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: Check one or many attributes option

Post by raiwa »

I sugest to use a separate option for each supplement like @heatherbell suggested. The other way to allow multiple selections for one option is not implemented in Phoenix core and would require heavy modifications in the options/attributes system of the whole shop.
A different thing would be to customize how these supplement options show to the customer on the product page and the product listing in the shopping cart, checkout_confirmation, order confirmation mail, invoice, packingslip etc.

You can use the option id's to make things show different for the size option and the supplements options.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27


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