Recent Topics

Integration of e-commerce functionality

Started by on Oct 03, 2017 – Contents updated: Oct 06, 2017

Oct 03, 2017 09:09    

Hi, today I have a question for you, I need to integrate variuos functionality like button (add to cart, add to wishlist), cart and related button (delete item, increase/decrease quantity, etc.), payment, so all I need for a slight e-commerce (yes probably a very difficult integration) on b2evo sites, now I need some extra table for the integration my questions is:

1) can I add an extra table to the installation of b2evo?
2) If I add a table that table are deleted when I upgrade b2evo?
3) this added table can generate some issue or error in b2evo?

thanks for any useful info.

Oct 05, 2017 07:30

@jinkazama82it a lot of development what you want to do... what's your plan? develop a plugin maybe?

If you do it through a plugin, install/uninstall tables could be controlled by the plugin itself using the mechanisms provided by b2evolution. As general rule, you can add any table you want to the DB (manually or via plugin) and b2evolution won't touch or conflict them. The only case in which those tables may be deleted is when you uninstall the plugin that create them.

Regards!

Oct 05, 2017 07:52

Are you therefore advising me to create a plugin to simplify my life?
I have to study how to create a plugin (I have never handed to that section of the manual)

Oct 05, 2017 12:41

This should get you going: (see: plugins/skeleton.plugin.php)

<?php
/**
 * -----------------------------------------------------------------------------------------
 * This file provides a skeleton to create a new {@link http://b2evolution.net/ b2evolution}
 * plugin quickly.
 * See also:
 *  - {@link http://b2evolution.net/man/creating-plugin}
 *  - {@link http://doc.b2evolution.net/stable/plugins/Plugin.html}
 * (Delete this first paragraph, of course)
 * -----------------------------------------------------------------------------------------
 *
 * This file implements the Foo Plugin for {@link http://b2evolution.net/}.
 *
 * @license GNU GPL v2 - {@link http://b2evolution.net/about/gnu-gpl-license}
 *
 * @copyright (c)2010 by Your NAME - {@link http://example.com/}.
 *
 * @package plugins
 *
 * @author Your NAME
 */
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );


/**
 * Foo Plugin
 *
 * Your description
 *
 * @package plugins
 */
class pluginname_plugin extends Plugin
{
	/**
	 * Variables below MUST be overriden by plugin implementations,
	 * either in the subclass declaration or in the subclass constructor.
	 */
	/**
	 * Human readable plugin name.
	 */
	var $name = 'Plugin Name';
	/**
	 * Code, if this is a renderer or pingback plugin.
	 */
	var $code = '';
	var $priority = 50;
	var $version = '0.1-dev';
	var $author = 'http://example.com/';
	var $help_url = '';

	/**
	 * Group of the plugin, e.g. "widget", "rendering", "antispam"
	 */
	var $group;


	/**
	 * Init: This gets called after a plugin has been registered/instantiated.
	 */
	function PluginInit( & $params )
	{
		$this->short_desc = $this->T_('Short description');
		$this->long_desc = $this->T_('Longer description. You may also remove this.');
	}


	
	/**
	 * This method should return your DB schema, consisting of a list of CREATE TABLE
	 * queries.
	 *
	 * The DB gets changed accordingly on installing or enabling your Plugin.
	 *
	 * If you want to change your DB layout in a new version of your Plugin, simply
	 * adjust the queries here and increase {@link Plugin::$version}, because this will
	 * request to check the current DB layout against the one you require.
	 *
	 * For restrictions see {@link db_delta()}.
	 *
	 * @see Plugin::GetDbLayout()
	 */	
	function GetDbLayout()
	{
		return $this->CreateDB();
	}
	
	/**
	* This method should return your DB schema, consisting of a list of CREATE TABLE
	* queries.
	*	
	* The DB gets changed accordingly on installing or enabling your Plugin.
	* @see Plugin::GetDbLayout()
	*	USE> Database	
	**/
	function CreateDB()
	{
		global $DB;
		
		
		$D_DB =	array(
			'CREATE TABLE IF NOT EXISTS '.$this->get_sql_table( 'sample' ).' (
					entry_ID int(10) NOT NULL AUTO_INCREMENT,
					Blog_ID int(11) NOT NULL,
					PRIMARY KEY entry_ID ( entry_ID ),
					UNIQUE ( entry_ID )
				) ENGINE = innodb DEFAULT CHARSET = utf8',
			);
		
		return $D_DB;
	}	
	/**
	 * Define the GLOBAL settings of the plugin here. These can then be edited in the backoffice in System > Plugins.
	 *
	 * @param array Associative array of parameters (since v1.9).
	 *    'for_editing': true, if the settings get queried for editing;
	 *                   false, if they get queried for instantiating {@link Plugin::$Settings}.
	 * @return array see {@link Plugin::GetDefaultSettings()}.
	 * The array to be returned should define the names of the settings as keys (max length is 30 chars)
	 * and assign an array with the following keys to them (only 'label' is required):
	 */
	function GetDefaultSettings( & $params )
	{
		return array();
	}


	/**
	 * Define the PER-USER settings of the plugin here. These can then be edited by each user.
	 *
	 * @see Plugin::GetDefaultSettings()
	 * @param array Associative array of parameters.
	 *    'for_editing': true, if the settings get queried for editing;
	 *                   false, if they get queried for instantiating
	 * @return array See {@link Plugin::GetDefaultSettings()}.
	 */
	function GetDefaultUserSettings( & $params )
	{
		return array();
	}


	/**
	 * Param definitions when added as a widget.
	 *
	 * Plugins used as widget need to implement the SkinTag hook.
	 *
	 * @return array
	 */
	function get_widget_param_definitions( $params )
	{
		return array();
	}


	// If you use hooks, that are not present in b2evo 1.8, you should also add
	// a GetDependencies() function and require the b2evo version your Plugin needs.
	// See http://doc.b2evolution.net/stable/plugins/Plugin.html#methodGetDependencies


	// Add the methods to hook into here...
	// See http://doc.b2evolution.net/stable/plugins/Plugin.html
}
?>

Oct 05, 2017 12:53

Insert into database sample:

	function record_data(  & $params  )
	{
		global $DB, $Blog;

		$SQL = 'INSERT INTO '.
				$this->get_sql_table( $params['Table_NAME'] ).
				' (file_ID, user_ID, Blog_ID, hit_datetime)
				VALUES ('.$DB->quote( $params['File_ID'] ).','.
				$DB->quote( $params['user_ID'] ).','.
				$DB->quote( $params['Blog_ID'] ).','.
				$DB->quote( $params['hit_datetime'] ).')';

		if( $DB->query( $SQL ) )
	}

and get from database:

	/**
	*
	**/
	function fetch_data( $key, $get = '*', $table = 'sample' )
	{
		global $DB;
		
		 return $DB->get_results(
		 'SELECT '.$get.' FROM '.
		 $this->get_sql_table( $table ).
		 ' WHERE lock = '.
		 $DB->quote( $key ) );
 
	}

Oct 06, 2017 07:53

I intend to use the gallery like a marketplace, so I need to create button/widget that read the ID of post into the gallery and add it into the user cart (a table) after that the widget cart need to be updated for show the number of item into the cart and if you click on it open the cart page, for me make a cart in PHP isn't difficult, but create it with an api is a diffent story, the cart page is another thing to make, but probably a good way is make a collection with some special standalone page or something of similar, I need to study a lot for make a good widget and all button/implementation.

If someone have some advice or different idea to do all this are welcome.

Oct 06, 2017 10:45

What you asking is completely possible to implement via a plugin, as it will handle all of that. It is also a rather huge project to undertake. I am not intending to discourage you, just that you will need to do your research and plan your development process well.


Form is loading...

powered by b2evolution – This forum is powered by b2evolution CMS, a complete engine for your website.