# Community Commerce product data in emails

**URL:** https://forums.concretecms.org/t/community-commerce-product-data-in-emails/2884
**Category:** eCommerce
**Created:** [April 21, 2022, 10:45am UTC](https://forums.concretecms.org/t/community-commerce-product-data-in-emails/2884 "2022-04-21T10:45:33Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![phowie74](https://forums.concretecms.org/user_avatar/forums.concretecms.org/phowie74/32/5178_2.png) [@phowie74](https://forums.concretecms.org/u/phowie74)
#### Post date: [April 21, 2022, 10:45am UTC](https://forums.concretecms.org/t/community-commerce-product-data-in-emails/2884/1 "2022-04-21T10:45:33Z")

</div>

I have just started using the fantastic community commerce package and have a query about accessing product data. I have had a request to include the product description in the notification emails so I created the override order\_receipt.php in application/mail to tweak the output but the $item object containing the ordered product data does not include the product description out of the box.

As the template is using the Product class I thought, much like accessing page properties, I could access a product using its id to get the product description…

```auto
$p = \Product::getByID($item->getID());
echo $p->getDesc();
```

but this says the class is not found?

As a workaround I have been able to update the src Product class to add the description to the $item object…

```auto
/**
* @ORM\return mixed
*/
public function getProductDescription()
{
    return $this->oiProductDescription;
}
/**
* @ORM\param mixed $oiProductDescription
*/
public function setProductDescription($oiProductDescription)
{
	$this->oiProductDescription = $oiProductDescription;
}
```

```auto
$productDescription = $product->getDesc();
```

which I can then add into the template as…

```auto
$item->getProductDescription();
```

but this is obviously not ideal as it is changing the core package files and subject to breaking when updating.

What would be the best way of accessing the product data within the order\_receipt.php template?

Thanks, any pointers gratefully received!

---

<div class="post-metadata">

### Author: ![mesuva](https://forums.concretecms.org/user_avatar/forums.concretecms.org/mesuva/32/4014_2.png) [@mesuva](https://forums.concretecms.org/u/mesuva)
#### Post date: [April 22, 2022, 8:45am UTC](https://forums.concretecms.org/t/community-commerce-product-data-in-emails/2884/2 "2022-04-22T08:45:27Z")

</div>

On the order item object ($item), there’s a function available called `getProductObject()`  
That’ll return the proper Product object, if it can still be found.

So you should be able to do something like this:

```auto
$product = $item->getProductObject();

if (is_object($product)) {
    $desc = $product->getDescription();
    echo $desc;
}

```

The way you were approaching it initially was sort of on the right track, but; you were using the ID of the _order item_, not the product, and the namespace of Product isn’t at the root level. So you would have have needed do to this:

```auto
$p = \Concrete\Package\CommunityStore\Src\CommunityStore\Product::getByID($item->getProductID());
if (is_object($p) {
    echo $p->getDescription();
}

```

That’s really just what getProductObject is doing, so either way does the same thing.

---

<div class="post-metadata">

### Author: ![phowie74](https://forums.concretecms.org/user_avatar/forums.concretecms.org/phowie74/32/5178_2.png) [@phowie74](https://forums.concretecms.org/u/phowie74)
#### Post date: [April 22, 2022, 9:42am UTC](https://forums.concretecms.org/t/community-commerce-product-data-in-emails/2884/3 "2022-04-22T09:42:17Z")

</div>

That is great - certainly a lot easier than I was trying to make it!

Thanks so much for taking the time to look at this, it works perfectly. Excellent explanation too so I can see exactly where I was going wrong and will be really helpful in future.

Thanks.  
Paul
