PHP to extract Product Color Options

Open to all! Ask other shopowners for help.
madruga
Member
Posts: 38
Joined: Thu Mar 16, 2023 12:43 pm
Phoenix Version:
Has thanked: 22 times
Been thanked: 2 times

PHP to extract Product Color Options

Post 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
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
burt
Core Team
Posts: 4550
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: PHP to extract Product Color Options

Post 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.
madruga
Member
Posts: 38
Joined: Thu Mar 16, 2023 12:43 pm
Phoenix Version:
Has thanked: 22 times
Been thanked: 2 times

Re: PHP to extract Product Color Options

Post 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.
dodgyhuw
Member
Posts: 14
Joined: Thu Jul 13, 2023 3:43 pm
Phoenix Version:
Has thanked: 11 times

Re: PHP to extract Product Color Options

Post 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?
madruga
Member
Posts: 38
Joined: Thu Mar 16, 2023 12:43 pm
Phoenix Version:
Has thanked: 22 times
Been thanked: 2 times

Re: PHP to extract Product Color Options

Post 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
You do not have the required permissions to view the files attached to this post.
Last edited by madruga on Thu Apr 04, 2024 6:16 pm, edited 1 time in total.
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: PHP to extract Product Color Options

Post by raiwa »

You may consider to use my options images addon:
app.php/addons/free_addon/options_images
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
madruga
Member
Posts: 38
Joined: Thu Mar 16, 2023 12:43 pm
Phoenix Version:
Has thanked: 22 times
Been thanked: 2 times

Re: PHP to extract Product Color Options

Post by madruga »

raiwa wrote: Wed Apr 03, 2024 2:11 pm You may consider to use my options images addon:
app.php/addons/free_addon/options_images
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.
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: PHP to extract Product Color Options

Post 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
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
madruga
Member
Posts: 38
Joined: Thu Mar 16, 2023 12:43 pm
Phoenix Version:
Has thanked: 22 times
Been thanked: 2 times

Re: PHP to extract Product Color Options

Post 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.
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: PHP to extract Product Color Options

Post by raiwa »

No problem if it works for you :+1: . 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. :)
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