Jump to content

Featured Replies

Posted

I’ve tried passing the purchases template from nexus in a block but with no luck . I want to display purchases displayed in the my purchases page Which is shown on the url 

My site.com/clients

im guessing it’s because the page controller is missing (cms rather than nexus) and the $purchases  variable is not passed .

Is there an easier way of doing this ?

Solved by bfarber

Go to solution
  • Solution

This is how we list purchases on that page, which you could emulate in a custom block

		$where = array( array( 'ps_member=?', \IPS\Member::loggedIn()->member_id ) );

		$parentContacts = \IPS\nexus\Customer::loggedIn()->parentContacts();
		if ( \count( $parentContacts ) )
		{
			$or = array();
			foreach ( $parentContacts as $contact )
			{
				$where[0][0] .= ' OR ' . \IPS\Db::i()->in( 'ps_id', $contact->purchaseIds() );
			}
		}
		$where[] = array( 'ps_show=1' );
		
		/* Get only the purchases from active applications */
		$where[] = array( "ps_app IN('" . implode( "','", array_keys( \IPS\Application::enabledApplications() ) ) . "')" );

		$purchases = array();
		foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_purchases', $where, 'ps_active DESC, ps_expire DESC, ps_start DESC' ), 'IPS\nexus\Purchase' ) as $purchase )
		{
			$purchases[ $purchase->parent ][ $purchase->id ] = $purchase;
		}
		\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->purchases( $purchases );

 

  • Author

Can I not simply call the template and output from that?

You have to pass the data to the template to display.

  • Author

ok thanks again,i tired adding in some of the code you stated above but it wont display anything.Sorry for asking so many questions

Recently Browsing 0

  • No registered users viewing this page.