[Skip to main content](#vessel-content)

#   onBeforeVoteCreate object

##

- **[DeeEmm](/forum/user/26410-deeemm "View DeeEmm's Profile")**
- [![DeeEmm's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar26410.jpg)](/forum/user/26410-deeemm "View DeeEmm's Profile") Topic Author
- [ Offline](/forum/user/26410-deeemm)

Less More

- Posts: 114
- Thank you received: 14
-
- [](http://deeemm.com)
-

13 years 2 days ago [\#131781](#131781) by [DeeEmm](/forum/user/26410-deeemm "View DeeEmm's Profile")  *[onBeforeVoteCreate object](/forum/31-development/863517-onbeforevotecreate-object#131781 "Hi.  I am trying to get the product id + product name within the onBeforeVoteCreate method via its $element object for a jomsocial activity stream plugin that I am writing but when I do a var dump on $object it appears to be empty.  The documentation does not give a breakdown of the $element object and a search of the forums gives me no results.  I've tried $element-&gt;product&#95;id but still I get nothing.  All help and advice greatly appreciated.  TIA  DM/")* was created by *[DeeEmm](/forum/user/26410-deeemm "View DeeEmm's Profile")*

Hi.

I am trying to get the product id + product name within the onBeforeVoteCreate method via its $element object for a jomsocial activity stream plugin that I am writing but when I do a var dump on $object it appears to be empty.

The documentation does not give a breakdown of the $element object and a search of the forums gives me no results.

I've tried $element-&gt;product_id but still I get nothing.

All help and advice greatly appreciated.

TIA

DM/

---

[ deeemm.com](http://deeemm.com)

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2MzUxNy1vbmJlZm9yZXZvdGVjcmVhdGUtb2JqZWN0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86541
- Thank you received: 14304
-
-

13 years 2 days ago [\#131797](#131797) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[onBeforeVoteCreate object](/forum/31-development/863517-onbeforevotecreate-object#131797 "Hi.  I am trying to get the product id + product name within the onBeforeVoteCreate method via its $element object for a jomsocial activity stream plugin that I am writing but when I do a var dump on $object it appears to be empty.  The documentation does not give a breakdown of the $element object and a search of the forums gives me no results.  I've tried $element-&gt;product&#95;id but still I get nothing.  All help and advice greatly appreciated.  TIA  DM/")*

Hi,

You should have done a var_dump on $element not $object if you defined the first variable of the function as $element.
The product id is available with $element-&gt;vote_ref_id
You can then load the product name like that:
$class = hikashop_get('class.product');
$product = $class-&gt;get($element-&gt;vote_ref_id);
echo $product-&gt;product_name;

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2MzUxNy1vbmJlZm9yZXZvdGVjcmVhdGUtb2JqZWN0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[DeeEmm](/forum/user/26410-deeemm "View DeeEmm's Profile")**
- [![DeeEmm's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar26410.jpg)](/forum/user/26410-deeemm "View DeeEmm's Profile") Topic Author
- [ Offline](/forum/user/26410-deeemm)

Less More

- Posts: 114
- Thank you received: 14
-
- [](http://deeemm.com)
-

13 years 1 day ago [\#131982](#131982) by [DeeEmm](/forum/user/26410-deeemm "View DeeEmm's Profile")  Replied by *[DeeEmm](/forum/user/26410-deeemm "View DeeEmm's Profile")* on topic *[onBeforeVoteCreate object](/forum/31-development/863517-onbeforevotecreate-object#131982 "Hi.  I am trying to get the product id + product name within the onBeforeVoteCreate method via its $element object for a jomsocial activity stream plugin that I am writing but when I do a var dump on $object it appears to be empty.  The documentation does not give a breakdown of the $element object and a search of the forums gives me no results.  I've tried $element-&gt;product&#95;id but still I get nothing.  All help and advice greatly appreciated.  TIA  DM/")*

Thanks Nicolas,

Quick and accurate advice as usual. ![:D](/media/kunena/emoticons/1.png ":D")

I incorrectly stated that I could not see the contents of *$object,* it was in fact *$element* as you suggested. My issue turned out to be that I could not see the results of the var_dump in the browser. I changed to use error_log(var_export($element, true)) and viewed the contents within the error.log instead and managed to get the full structure.

For anyone else looking for the structure of the $element object it is as follows:
Code:

stdClass::__set_state(array( 'hikashop_vote_type' =&gt; 'comment', 'vote_ref_id' =&gt; 2, 'user_id' =&gt; 2, 'pseudo_comment' =&gt; '0', 'email_comment' =&gt; '0', 'vote_type' =&gt; 'product', 'vote' =&gt; 0, 'comment' =&gt; 'hhhmmmnnn', ))

DM/

---

[ deeemm.com](http://deeemm.com)

The following user(s) said Thank You: [Xavier](/forum/user/4105-xavier "View Xavier's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2MzUxNy1vbmJlZm9yZXZvdGVjcmVhdGUtb2JqZWN0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.058 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
