Adding Additional Details to Product Cards

Open to all! Ask other shopowners for help.
Post Reply
levelup
Member
Posts: 15
Joined: Tue Mar 30, 2021 6:16 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 1 time

Adding Additional Details to Product Cards

Post by levelup »

I'm attempting to update an old version (1.0.5) to the latest version and there are some custom buttons/details we need to add to the product card for the product listing page.

So, for example, we want to add a model number and manufacturer info to the cards. How would we add this info exactly? I'd hate to overwrite any core code.

I see the following snippet in "templates/default/includes/components/product_card.php":

Code: Select all

<h5 class="card-title"><a href="<?= $product->get('link') ?>"><?= $product->get('name') ?></a></h5>
How can I create something like "$product->get('model_number')"? Or, could I still use something like $listing['products_model'] here?


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

Re: Adding Additional Details to Product Cards

Post by Kofod95 »

levelup wrote: Fri Feb 11, 2022 4:59 pm "templates/default/includes/components/product_card.php":
Copy that file to the override-template or whatever you might have as selected template.

Code: Select all

$product->get('link')
Says from the class "product" execute the function "get" on the key inside the "()"
Returning to product_card.php I see that it just uses the name of what it wants in the "get-function"

Code: Select all

$product->get('image')
and

Code: Select all

$product->get('name')
So I thought; Why not just try:

Code: Select all

<h6><?= $product->get('model') ?> </h6>
and it worked. I would expect it to work like that with any entries in the products and the products_description tables.
Manufacturers would be a little more complicated, as the data needed for the manufacturer is in the manufacturers table, but I think this should show the name of the manufacuter:

Code: Select all

	<h6><?= $product->get('brand')->getData('manufacturers_name')	?> </h6>
(Might throw error if no manufacturer is set)

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
levelup
Member
Posts: 15
Joined: Tue Mar 30, 2021 6:16 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 1 time

Re: Adding Additional Details to Product Cards

Post by levelup »

Kofod95 wrote: Fri Feb 11, 2022 9:31 pm
levelup wrote: Fri Feb 11, 2022 4:59 pm "templates/default/includes/components/product_card.php":
Copy that file to the override-template or whatever you might have as selected template.

Code: Select all

$product->get('link')
Says from the class "product" execute the function "get" on the key inside the "()"
Returning to product_card.php I see that it just uses the name of what it wants in the "get-function"

Code: Select all

$product->get('image')
and

Code: Select all

$product->get('name')
So I thought; Why not just try:

Code: Select all

<h6><?= $product->get('model') ?> </h6>
and it worked. I would expect it to work like that with any entries in the products and the products_description tables.
Manufacturers would be a little more complicated, as the data needed for the manufacturer is in the manufacturers table, but I think this should show the name of the manufacuter:

Code: Select all

	<h6><?= $product->get('brand')->getData('manufacturers_name')	?> </h6>
(Might throw error if no manufacturer is set)

//Daniel
Amazing and detailed post, thank you so much for your time. I'll look into it further from here, I really appreciate your insight!
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Adding Additional Details to Product Cards

Post by Kofod95 »

Happy to help!

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide


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