Jump to content

Welcome to the forum:

Welcome to the iThemes forum. We've created several tutorial video's to help you get you started with using the forum, please check them out!

Also take note of the forum guidelines.

Support hours:

Our moderators actively respond to forum support requests during normal business hours which are Monday-Friday, 8am - 5pm Central Standard Time, typically within one business day. Although some moderators choose to work during the weekends, we can not guarantee immediate attention to your requests. Thanks for understanding.

What is included with support:

Premium support includes theme/plugin issues such as: bugs encountered under normal operation, how to use basic features, basic WordPress help, and basic help with customization (meaning we point you to resources and will help in more depth as time allows). More information.

Memorial Weekend:

Monday, May 25 2015 is Memorial Day. Please note that the iThemes offices are closed during National Holidays.
Support will resume on Tuesday May 26.

Adding An It_Exchange_Email_Notification_Shortcode_Functions Is Next To Impossible Because Of Private Property Access

email private developer code shortcodes

2 replies to this topic

#1 ironbound


    Advanced Member

  • Members
  • Others: Toolkit
  • PipPipPip
  • 99 posts
  • LocationNew York

Posted 20 March 2014 - 12:58 PM

Hi Guys,

The class IT_Exchange_Email_Notifications handles the sending of receipts. Using the it_exchange_email_notification_shortcode_functions filter we can add our own custom short code. However, in the ithemes_exchange_email_notification_shortcode method, the parameter that is passed to the function earlier defined with that filter is the $this object. Normally this wouldn't be a problem, however, in order to get any meaningful use out of our custom short code function, we need to access the customer id. Unfortunately, those properties are defined as private:

private $transaction_id;
private $customer_id;
private $user;

This isn't a problem for the default iThemes Exchange short codes because they are all contained with in the IT_Exchange_Email_Notifications class, so they get access. But because our function is outside of the IT_Exchange_Email_Notifications class we can't access them.

As such we have to do an ugly "hack" using reflection as follows:

* @param $args IT_Exchange_Email_Notifications
* @return string
public static function email_shortcode_print_billing_address( $args ) {
$IT_Exchange_Email_Notifications_Reflection = new ReflectionClass( get_class( $args ) ); // we have to use reflection because the damn $customer_id property is private
$secret = $IT_Exchange_Email_Notifications_Reflection->getProperty( 'customer_id' );
$secret->setAccessible( true );
$user_id = $secret->getValue( $args );

$content = it_exchange_get_formatted_billing_address( it_exchange_get_customer_billing_address( $user_id ) );

return $content;

I'd propose that either those properties are marked as public, or that they are passed in as additional parameters.

Additionally, are there any plans to move iThemes Exchange to a more open source model such as WooCommerce or EDD? As in, hosting the code on GitHub and allowing developers to submit pull requests, and add issues? It seems that one of the many things that makes all of these other platforms so successful is the ability for developers to contribute back to the project. I know personally, during the current development of a site using iThemes Exchange I have come across many small bugs etc... And while I have of course filed tickets here, it is understandable that it would take a while for you fabulous folks to get to them, because they might be lower down on the priority list, etc... That is totally understandable, and makes sense. I only wish that there was someway that I, and many other developers could contribute back to the project, and make iThemes Exchange even cooler. It seems like "open sourcing" ( I know it is a GPL plugin, hence the quotes ) would be a tremendous benefit to the community, and the future development as a plugin as well. And I'm sure you guys have thought about this already, and I'd imagine one of the drawbacks being that you'd have to make that someones job — but it seems that even though it would consume company hours, it'd be really great in the long run.

Sorry for my rambling, but it is just something that has been on my mind...


#2 Elise Alley

Elise Alley

    iThemes Support

  • Administrators
  • Others: All Plugins, All Themes, Members, Moderators, Toolkit, Webdesign
  • 6,498 posts
  • LocationOklahoma City, OK

Posted 20 March 2014 - 02:14 PM

Hi Tim,

I've spoken with the developers and they agree that those should be public.  They are going to change it in core for the next release.

As for GitHub - this is something we've discussed doing.  However, it's something that is still a ways down the road, and I can't guarantee that it will happen even then.  Like I said, we've discussed it, but I just don't want to make any promises!  :)

Let us know if you have any other questions.



#3 ironbound


    Advanced Member

  • Members
  • Others: Toolkit
  • PipPipPip
  • 99 posts
  • LocationNew York

Posted 20 March 2014 - 02:23 PM

Thanks Elise!

Makes sense. I'd absolutely love to see it happen.



Reply to this Topic

If this topic is marked RESOLVED or INFORMATION, or if you are NOT experiencing EXACTLY the same issue, please start a new topic to provide the details of your problem. If the solution provided doesn't work for you, you should start a new topic. If you feel this thread contains relevant information, you may include a link to it in your new topic. To ensure that we can process your support request efficiently, ALWAYS include a link to your site, and/or the page your request is related to. When posting your question or request on the forum, please be as concise and specific as possible. The shorter and more to the point you can make your request, the better.

For BackupBuddy related issues, be sure to include the status log from your most recent backup.

CLICK HERE to start a new topic in the Exchange ecommerce plugin forum.


Also tagged with one or more of these keywords: email, private, developer, code, shortcodes

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users