Page 1 of 2
PHP to extract Product Color Options
Posted: Sun Oct 29, 2023 4:08 pm
by madruga
Hi Phoenix Gurus,
Please can anyone tell me how I can extract the available color options for a product on the
product_info page? I presently have a dropbox which shows all the colors for the product but I want to also list these colors under the product main image with something like:
Available Colors: Black, Grey etc etc.
Any help with this is very much appreciated.
Colour Selection.jpg
Re: PHP to extract Product Color Options
Posted: Sun Oct 29, 2023 4:56 pm
by burt
You can see how a list is made by inspecting the code of the options/attributes module.
There are in fact two such modules;
includes/modules/pi/product_info/pi_options_attributes.php
includes/modules/content/product_info/cm_pi_options_attributes.php
You need a cut down version that;
1/ allows you to choose an "option"
2/ in the TPL file, lists the attributes of that chosen option [or obviously none if the option is not applied to the product]
Seems straightforward and in fact super simple, probably 20 minutes if you know code or a few hours if you have to learn things as you go along. Get your hands dirty and give it a go.
Re: PHP to extract Product Color Options
Posted: Sun Oct 29, 2023 6:20 pm
by madruga
burt wrote: ↑Sun Oct 29, 2023 4:56 pm
You can see how a list is made by inspecting the code of the options/attributes module.
There are in fact two such modules;
includes/modules/pi/product_info/pi_options_attributes.php
includes/modules/content/product_info/cm_pi_options_attributes.php
You need a cut down version that;
1/ allows you to choose an "option"
2/ in the TPL file, lists the attributes of that chosen option [or obviously none if the option is not applied to the product]
Seems straightforward and in fact super simple, probably 20 minutes if you know code or a few hours if you have to learn things as you go along. Get your hands dirty and give it a go.
Thanks
@burt
I'll give it a go and see how I get on.
Re: PHP to extract Product Color Options
Posted: Tue Oct 31, 2023 11:00 am
by dodgyhuw
@burt @madruga
I was thinking about doing this on one of my stores. I'd be great if any of you can provide or share this solution. This looks very complex, well at least for those of us with limited knowledge. @burt Please can you help with this?
Re: PHP to extract Product Color Options
Posted: Wed Apr 03, 2024 12:10 pm
by madruga
I finally got this working on all my sites. It was very complex for a novice like me. But thanks
@burt for the pointers to the attributes codes, I was able to take sections I needed and modified code to what what I wanted.
colours.jpg
Re: PHP to extract Product Color Options
Posted: Wed Apr 03, 2024 2:11 pm
by raiwa
You may consider to use my options images addon:
app.php/addons/free_addon/options_images
Re: PHP to extract Product Color Options
Posted: Thu Apr 04, 2024 5:31 pm
by madruga
Thank you but your addon has the colours in the selectbox. So, this requires a user to first click the selectbox before they can see the colours, and I don't know if they see the product in the colour selected. This is not ideal. Most online shops, especially clothing stores have the colour options displayed next to the product, as well as having a selectbox to select a colour to add to the basket.
In my case, you can see the actual colours and click on any of them to see my products in the colour you want. I have four clothing brands and this is what my customers want to see. Selecting a colour in the selectbox on the other hand, is just for adding the product to basket.
Re: PHP to extract Product Color Options
Posted: Thu Apr 04, 2024 6:01 pm
by raiwa
Use qtpro together with options images and you can display the options as radios list and show all colours without the need to click on select menu. In addition you get stock control for options/attributes.
https://phoenixcart.org/forum/app.php/ ... ddon/qtpro
Re: PHP to extract Product Color Options
Posted: Thu Apr 04, 2024 6:20 pm
by madruga
raiwa wrote: ↑Thu Apr 04, 2024 6:01 pm
Use qtpro together with options images and you can display the options as radios list and show all colours without the need to click on select menu. In addition you get stock control for options/attributes.
https://phoenixcart.org/forum/app.php/ ... ddon/qtpro
Thank you! My solution works great for me as is, and no need for addons. I'm a minimalist, so the simpler, the better.
Re: PHP to extract Product Color Options
Posted: Thu Apr 04, 2024 6:33 pm
by raiwa
No problem if it works for you

. Just wondered if your customers will always correct identify the colour option name in the pull down with the sample colours.
You do not need to use the available Addons. You could recode the option selection to a radio list which shows the colour samples in the radio description and make it easier for your clients. Just an idea.
