Jump to content

Output my purchases in a block


Go to solution Solved by bfarber,

Recommended Posts

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 ?

Link to comment
Share on other sites

  • 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 );

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...