Jump to content

COMMERCE: Suggest only displaying 15 Purchases


IPCommerceFan

Recommended Posts

Posted

Hi,

We have some customers who have hundreds of purchases on their account, and it can take a really long time just to load their customer page due to, in our case, loading over 700 purchases into view.  

It'd be great if we could limit the number that are loaded to 15 just like invoices and support requests, and just have an option to "display all Purchases".

  • 1 month later...
Posted

I ended up writing a plugin to solve this.

Hooked into:

\IPS\nexus\extensions\core\MemberACPProfileBlocks\Purchases  

//<?php

/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
	exit;
}

class hook406 extends _HOOK_CLASS_
{
	/**
	 * Get output
	 *
	 * @return	string
	 */
	public function tabOutput( $activeTabKey )
	{
		if ( $this->_purchases === NULL )
		{
			$where = array();
			$where[] = array( 'ps_member=?', $this->member->member_id );

			switch ( $activeTabKey )
			{
				case 'active':
					$where[] = array( 'ps_active=1' );
					break;
				case 'canceled':
					$where[] = array( 'ps_cancelled=1' );
					break;
				case 'expired':
					$where[] = array( 'ps_active = 0 and ps_cancelled = 0 and ps_expire <?', \IPS\DateTime::create()->getTimestamp() );
					break;
			}

			$this->_purchases = \IPS\nexus\Purchase::tree( $this->member->acpUrl()->setQueryString( 'blockKey', 'nexus_Purchases' ), $where );
            $this->_purchases->rootsPerPage = 15;
			$this->_purchases->getTotalRoots = function()
           
			{
              
				return NULL;
			};
		}
		return $this->_purchases;
	}

}

I don't have a "View All Purchases" button currently, nor is there pagination which would be ideal, but this solves the immediate issue of having to wait for hundreds of purchases to load.  👍

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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