Thread: IPB 4 Commerce Custom Actions Plugin

Results 1 to 4 of 4
  1. #1 IPB 4 Commerce Custom Actions Plugin 
    Server Developer
    Argyros's Avatar
    Join Date
    Apr 2011
    Posts
    498
    Thanks given
    25
    Thanks received
    31
    Rep Power
    23
    So I'm finally getting around to releasing this after many consideration.
    I have just got tired of seeing soo many servers using a standalone donation/monetizing system when IPB already has a powerful one.
    Unlike IPB 3.x, custom actions settings were removed in the new IPB 4; however, it's possible to still allow custom actions using plugins.
    not only is this better, but nexus/commerce is a better system than any custom one, not only does this support multiple payment gateways, but you have full access to it via IPB ACP.
    Staff members that have the restrictions can edit and update transactions in it without having to access PayPal or any other gateway system.

    Currently, I'm not up to really explain too much detail on how to fully customize this plugin, but if you have some experience messing around with IPB and websites you should get the picture.

    Save the file as .xml format and install it via IPB plugins
    Spoiler for VIP Custom Actions.xml:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <plugin name="VIP Custom Actions" version_long="10000" version_human="1.0.0" author="Argyros" website="" update_check=""><hooks><hook type="C" class="\IPS\nexus\Package" filename="5b3c925ad8b583cc3f6c0777e6c6c753"><![CDATA[//<?php
    
    class hook14 extends _HOOK_CLASS_
    {
    public function onPurchaseGenerated( \IPS\nexus\Purchase $purchase, \IPS\nexus\Invoice $invoice)
        {		
    			try
    			{
    	  		if ( in_array( $this->id, array( 1 ) ) )
    		    { 
    	        $memberid = $purchase->member->member_id;  
    			$sql = "SELECT field_2 FROM core_pfields_content WHERE member_id=$memberid";
    	        $sql2 = "SELECT name FROM core_members WHERE member_id=$memberid";
    			$ingame = \IPS\Db::i()->query($sql);
    	        $member = \IPS\Db::i()->query($sql2);
    	       	while ($row = $ingame ->fetch_assoc()) {
    	        while ($row2 = $member ->fetch_assoc()) {
    			}
    			\IPS\Db::i()->insert( 'vips', array(
    					'username'	=> $row["field_2"],
    	          		'member' => $memberid,
    					'name'	=> $row2["name"],
    					'level'	=> "1"
    				) );
    			}	
    	        }
    	        } 
    	    	}
    			}			
    	  	return parent::onPurchaseGenerated( $purchase, $invoice );
    		}
    		catch ( \RuntimeException $e )
    		{
    			if ( method_exists( get_parent_class(), __FUNCTION__ ) )
    			{
    				return call_user_func_array( 'parent::' . __FUNCTION__, func_get_args() );
    			}
    			else
    			{
    				throw $e;
    			}
    		}
    	}
      	public function onExpire( \IPS\nexus\Purchase $purchase )
    	{
    		try
    		{
    	    if ( in_array( $this->id, array( 1 ) ) )
    		    {   
    	    $memberid = $purchase->member->member_id;
    		$sql = "UPDATE vips SET level = 0 WHERE member=$memberid";
    	    \IPS\Db::i()->query($sql);
    	    }
    		}
    		catch ( \RuntimeException $e )
    		{
    			if ( method_exists( get_parent_class(), __FUNCTION__ ) )
    			{
    				return call_user_func_array( 'parent::' . __FUNCTION__, func_get_args() );
    			}
    			else
    			{
    				throw $e;
    			}
    		}
    	}
    	public function onCancel( \IPS\nexus\Purchase $purchase )
    	{
    		try
    		{
    	    if ( in_array( $this->id, array( 1 ) ) )
    		    {   
    	    $memberid = $purchase->member->member_id;
    		$sql = "UPDATE vips SET level = 0 WHERE member=$memberid";
    	    \IPS\Db::i()->query($sql);
    	    }
    		}
    		catch ( \RuntimeException $e )
    		{
    			if ( method_exists( get_parent_class(), __FUNCTION__ ) )
    			{
    				return call_user_func_array( 'parent::' . __FUNCTION__, func_get_args() );
    			}
    			else
    			{
    				throw $e;
    			}
    		}
    	}
      	public function onRenew( \IPS\nexus\Purchase $purchase, $cycles )
        {
    	try
    	{
    	      if ( in_array( $this->id, array( 1 ) ) )
    		    { 
    	    $memberid = $purchase->member->member_id;
    		$sql = "UPDATE vips SET level = 1 WHERE member=$memberid";
    	    \IPS\Db::i()->query($sql); 
    	      }
    	}
    	catch ( \RuntimeException $e )
    	{
    		if ( method_exists( get_parent_class(), __FUNCTION__ ) )
    		{
    			return call_user_func_array( 'parent::' . __FUNCTION__, func_get_args() );
    		}
    		else
    		{
    			throw $e;
    		}
    	}
        }
    	
    	/**
    	 * On Purchase Reactivated (renewed after being expired or reactivated after being canceled)
    	 *
    	 * @param	\IPS\nexus\Purchase	$purchase	The purchase
    	 * @return	void
    	 */
    	public function onReactivate( \IPS\nexus\Purchase $purchase )
    	{
    		try
    		{
    	      if ( in_array( $this->id, array( 1 ) ) )
    		    { 
    		$memberid = $purchase->member->member_id;
    		$sql = "UPDATE vips SET level = 1 WHERE member=$memberid";
    	    \IPS\Db::i()->query($sql);
    	      }
    		}
    		catch ( \RuntimeException $e )
    		{
    			if ( method_exists( get_parent_class(), __FUNCTION__ ) )
    			{
    				return call_user_func_array( 'parent::' . __FUNCTION__, func_get_args() );
    			}
    			else
    			{
    				throw $e;
    			}
    		}
    	}  
    }]]></hook></hooks><tasks/><widgets/><htmlFiles/><cssFiles/><jsFiles/><resourcesFiles/><lang/><versions><version long="10000" human="1.0.0"><![CDATA[//<?php
    
    
    /* To prevent PHP errors (extending class does not exist) revealing path */
    if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
    {
    	header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
    	exit;
    }
    
    /**
     * Install Code
     */
    class ips_plugins_setup_install
    {
    	/**
    	 * ...
    	 *
    	 * @return	array	If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
    	 */
    	public function step1()
    	{
    		
    
    		return TRUE;
    	}
    	
    	// You can create as many additional methods (step2, step3, etc.) as is necessary.
    	// Each step will be executed in a new HTTP request
    }]]></version><version long="10001" human="1.0.1"><![CDATA[//<?php
    
    
    /* To prevent PHP errors (extending class does not exist) revealing path */
    if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
    {
    	header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
    	exit;
    }
    
    /**
     * 1.0.1 Upgrade Code
     */
    class ips_plugins_setup_upg_10001
    {
    	/**
    	 * ...
    	 *
    	 * @return	array	If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
    	 */
    	public function step1()
    	{
    		
    
    		return TRUE;
    	}
    	
    	// You can create as many additional methods (step2, step3, etc.) as is necessary.
    	// Each step will be executed in a new HTTP request
    }]]></version></versions></plugin>


    Basically what this does is allows for you to use the IP commerce system as a donation system, allowing you to do custom actions on payment.
    Those custom actions can be anything including inserting data into a table which is currently being done.
    if ( in_array( $this->id, array( 1 ) ) ) refers to the product id.
    field_2 refers to a custom field that needs to be made, if you're already using field_2 then change it to whatever the next custom field is called.

    In short what does it does is insert some data into a table called VIPs.
    The data that gets inserted is
    Player's Name
    Memeber's forum id
    Member's forum name
    product/item value.

    You might need to make a new value called "claimed", the plugin isn't 100% finished, but you could use any currenty server sided donation system that retrieves data via mysql.
    Reply With Quote  
     


  2. #2  
    IrieScape


    Join Date
    Dec 2011
    Posts
    854
    Thanks given
    57
    Thanks received
    123
    Rep Power
    107
    flawless
    Spoiler for There is no place like 127.0.0.1:
    Attached image

    Reply With Quote  
     

  3. #3  
    Vanishing Into Smok3

    sean kiesler's Avatar
    Join Date
    Mar 2014
    Posts
    429
    Thanks given
    250
    Thanks received
    135
    Rep Power
    1341
    Awesome release, thank you for sharing.
    Attached image

    Discord: storm#3920
    Reply With Quote  
     

  4. #4  
    hopeless grinder
    peer1k's Avatar
    Join Date
    Aug 2014
    Posts
    227
    Thanks given
    110
    Thanks received
    60
    Rep Power
    53
    I smell some grave digging..
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 3
    Last Post: 05-15-2016, 02:53 PM
  2. Abstergo | IPB forum services | Custom Skins
    By Thorrin in forum Website Development
    Replies: 3
    Last Post: 08-28-2015, 08:33 PM
  3. Replies: 18
    Last Post: 06-10-2015, 01:55 AM
  4. Custom action buttons ...
    By mr selby in forum Help
    Replies: 3
    Last Post: 06-06-2014, 04:36 AM
  5. Replies: 4
    Last Post: 12-01-2011, 07:27 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •