IPCommerceFan Posted September 3, 2019 Posted September 3, 2019 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".
IPCommerceFan Posted October 29, 2019 Author Posted October 29, 2019 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. 👍
Recommended Posts
Archived
This topic is now archived and is closed to further replies.