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
Trying to make a product conditions addon
- burt
- Core Team
- Posts: 4550
- Joined: Tue Oct 29, 2019 9:37 am
- Phoenix Version: v1.1.0.8
- : Buy Me A Beverage
- Has thanked: 252 times
- Been thanked: 412 times
Re: Trying to make a product conditions addon
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.
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.
I am not here to build for you.
I am here to build with you. Let's help each other.
I am here to build with you. Let's help each other.
-
cbs
- Member
- Posts: 46
- Joined: Tue Oct 26, 2021 9:42 am
- Phoenix Version: v1.1.0.6
- Has thanked: 8 times
- Been thanked: 6 times
Re: Trying to make a product conditions addon
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.
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.
- burt
- Core Team
- Posts: 4550
- Joined: Tue Oct 29, 2019 9:37 am
- Phoenix Version: v1.1.0.8
- : Buy Me A Beverage
- Has thanked: 252 times
- Been thanked: 412 times
Re: Trying to make a product conditions addon
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!).
as
Schema requires one of New\Used\Damaged\Refurbished (I may be mistaken so check up on that before changing!).
I am not here to build for you.
I am here to build with you. Let's help each other.
I am here to build with you. Let's help each other.
-
cbs
- Member
- Posts: 46
- Joined: Tue Oct 26, 2021 9:42 am
- Phoenix Version: v1.1.0.6
- Has thanked: 8 times
- Been thanked: 6 times
Re: Trying to make a product conditions addon
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.
-
frankl
- Builder
- Posts: 159
- Joined: Tue Feb 23, 2021 8:39 pm
- Phoenix Version: v1.1.0.4
- Has thanked: 17 times
- Been thanked: 25 times
Re: Trying to make a product conditions addon
DamagedCondition
NewCondition
RefurbishedCondition
UsedCondition
i.e. 'itemCondition' => 'https://schema.org/NewCondition',
https://schema.org/OfferItemCondition
NewCondition
RefurbishedCondition
UsedCondition
i.e. 'itemCondition' => 'https://schema.org/NewCondition',
https://schema.org/OfferItemCondition
Check out my addons - app.php/addons/author/frankl/contributions
-
cbs
- Member
- Posts: 46
- Joined: Tue Oct 26, 2021 9:42 am
- Phoenix Version: v1.1.0.6
- Has thanked: 8 times
- Been thanked: 6 times
Re: Trying to make a product conditions addon
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
The OG & Schema if statement for New\Used\Damaged\Refurbished work the way need them(hopefully).
Any feedback would be nice.
Thank you
You do not have the required permissions to view the files attached to this post.
Re: Trying to make a product conditions addon
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.
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.
-
cbs
- Member
- Posts: 46
- Joined: Tue Oct 26, 2021 9:42 am
- Phoenix Version: v1.1.0.6
- Has thanked: 8 times
- Been thanked: 6 times
Re: Trying to make a product conditions addon
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
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.
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.