Home » Resources » Documentation » Get Involved » Extending Wp-e-Commerce

Extending Wp-e-Commerce

So you have a Wp-e-Commerce website, but require some additional features that don’t come bundled with the plugin? Before you take an axe to the wp-e-commerce files, are you sure you have to? Wp-e-commerce has a ton of Hooks in place, and if we don’t have the right hook in the right place for what you want to achieve we are generally happy to add them in if you let us know through the forums.

There is some better resources available to date and you can find out more about them here:
Extending WP e-Commerce


You can either make a new Plugin and activate it, or you could do it through Modules (Also known as Extensions, and Upgrades) I call them Modules cause well it makes sense to me :P
Modules are like Plugins, but you don’t have to activate it in your Plugins page.

WARNING: Programming Code Ahead
In the following article you may encounter programming terms that are not explained in the usual level of detail required for understanding by non-programmers.

I’ve made a basic frame for building my wp-e-commerce modules quick and effortless. It’s really simple, it does the first two things every module needs… well sort of apart from actually DOING anything.

  1. Has an Upgrades File Header
  2. Adds a new page to the Products sidebar in wp-admin

Step 1 : Location and File Structure

All upgrades either live in this folder or in a folder in this folder
wp-content/uploads/wpsc/upgrades

All upgrades have a main file with its comment header (just like themes and plugins with WordPress)


/*
Upgrade Name:WPSC Skeleton Module
Upgrade URI: http://www.screamingcodemonkey.com
Description: A skeleton module for wpec
Version: 0.0
Author: ScreamingCodeMonkey
Author URI: http://www.screamingcodemonkey.com
*/

Step 2 : Adding a new page to the wp-admin Wp-e-Commerce sidebar

Then Some but not all modules/upgrades require a new page in the ‘Products’ wp-admin Sidebar Widget:


if (is_admin()) {
function wpsc_add_modules_admin_pages($page_hooks, $base_page) {
$page_hooks[] = add_submenu_page($base_page, __('-New Page','wpsc'), __('-New Page','wpsc'), 7, 'wpsc-module-admin', 'wpsc_display_admin_pages');
return $page_hooks;
}
add_filter('wpsc_additional_pages', 'wpsc_add_modules_admin_pages',10, 2);
}


It’s pretty basic, hope you find this useful. You can download a .zip of the moduleSkeleton here.

This Post was written by Screaming Code Monkey for Instinct and the Wp-e-Commerce Community.