Page 1 of 2
Trying to make a product conditions addon
Posted: Mon Sep 08, 2025 12:27 pm
by cbs
Hi,
Hopefully someone will get chance to double check this, I've been working on an item condition addon and I think it is finished but would like some input in case there is something that has been missing or not best practice. I would really like to learn more and improve my skills.
The opengraph and schema header tags are modified default ones, hopefully that is ok. opengraph and schema only allow new, used and refurbished as conditions so if you input anything other than new or used it appears as refurbished.
Is there a better way to do the alteration to product_card.php? I would like it not to be an override template but couldn't find any other way to do it.
Thanks
Re: Trying to make a product conditions addon
Posted: Mon Sep 08, 2025 12:53 pm
by burt
Thoughts, off the top of my head;
1. admin side, does the condition need to be i18n (language based) ?
- could you simply store New|Used|Damaged|Refurbished in `products` ?
2. Product Card
You could use a Hook `injectProductCard` to get this data into the card
3. OG & Schema
You could use a Hook `injectHtOpenGraph` & `injectHtProductSchema` to get the condition data to show
I believe there are examples of such Hooks floating about in the forum/addons.
Re: Trying to make a product conditions addon
Posted: Mon Sep 08, 2025 1:00 pm
by cbs
Thank you for the input.
The thinking behind the admin side was to allow things like "Grade A" etc. Happy to change it if that would be better.
I didn't know that Hook inject was possible on those files will change that now.
Re: Trying to make a product conditions addon
Posted: Mon Sep 08, 2025 1:08 pm
by burt
There might be an issue with (eg) `Grade A`
as
Schema requires one of New\Used\Damaged\Refurbished (I may be mistaken so check up on that before changing!).
Re: Trying to make a product conditions addon
Posted: Mon Sep 08, 2025 1:14 pm
by cbs
If I have done it correctly anything that isn't new or used will be deemed as refurbished, didn't realise damaged was an option in schema will add in the if statement.
Re: Trying to make a product conditions addon
Posted: Sat Sep 13, 2025 12:47 am
by frankl
DamagedCondition
NewCondition
RefurbishedCondition
UsedCondition
i.e. 'itemCondition' => '
https://schema.org/NewCondition',
https://schema.org/OfferItemCondition
Re: Trying to make a product conditions addon
Posted: Mon Oct 13, 2025 1:22 pm
by cbs
Hopefully this has the Hooks working correctly and displaying it all in the correct places.
The OG & Schema if statement for New\Used\Damaged\Refurbished work the way need them(hopefully).
Any feedback would be nice.
Thank you
Re: Trying to make a product conditions addon
Posted: Sun Jun 14, 2026 9:15 pm
by cwh2000
Installing it under admin/modules/layout receive
Fatal error: Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF NOT EXISTS item_condition VARCHAR(64)' at line 1 in /home/neperfmust/public_html/catalog/includes/system/versioned/1.0.8.1/database_core.php:67 Stack trace: #0 /home/neperfmust/public_html/catalog/includes/system/versioned/1.0.8.1/database_core.php(67): mysqli->query('ALTER TABLE pro...', 0) #1 /home/neperfmust/public_html/catalog/includes/modules/pi/product_info/pi_item_condition.php(66): database_core->query('ALTER TABLE pro...') #2 /home/neperfmust/public_html/catalog/nepmadmin6470/includes/actions/modules/install.php(23): pi_item_condition->install() #3 /home/neperfmust/public_html/catalog/nepmadmin6470/includes/segments/process_action.php(19): require('/home/neperfmus...') #4 /home/neperfmust/public_html/catalog/nepmadmin6470/modules.php(50): require('/home/neperfmus...') #5 {main} thrown in /home/neperfmust/public_html/catalog/includes/system/versioned/1.0.8.1/database_core.php on line 67
It is installed and works well, although I we have a products_condition field in the products table. I tired to modify it to use that field, without success.
Re: Trying to make a product conditions addon
Posted: Mon Jun 15, 2026 8:23 am
by cbs
That's odd, I've installed it a few times and not got that error. Did item_condition get created when installing? Which version of Phoenix are you trying to install it on? Also Which version of MySQL are you using?
Re: Trying to make a product conditions addon
Posted: Mon Jun 15, 2026 10:26 am
by cwh2000
item_condition did not get created in the products_description table. I created it to see this addon work properly. CE Phoenix v1.0.9.9 and PHP 8.1
How can I change it to use the products table with products_condition field? I tried to change the files addCondition & pi_item_condition, but no luck.