• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WPArena

WPArena

WPArena is a premium online resource site of WordPress and is focused on providing excellent WordPress Tutorials, Guides, Tips, and Collections.

  • News
    • Opinion
  • Tutorials
  • Reviews
    • Themes
    • Plugins
  • Comparisons
  • Collections
    • Education Themes
    • Genesis Child Themes
    • Best Responsive Themes
    • Medical WordPress Themes
    • Finance & Business Themes
    • Crowdfunding Themes
  • Resources
    • Inspiration
  • Services
WPArena » Tutorials
Tutorials

How To Add Multiple Product Categories To WP eCommerce Plugin

Avatar of Noor Mustafa Raza Noor Mustafa Raza Updated: October 12, 2020

FacebookTweetPinLinkedInEmailPrint

WP e-Commerce is a free WordPress Shopping Cart Plugin that lets customers buy your products, services and digital downloads online. WP Shopping Cart Plugin is a paid plugin, it seems to be of better quality than the free versions as well as slightly easier to use. It has more features as compare to the free one. Even there are WordPress Themes with eCommerce features, you can find the theme on the following links:

  • Best WordPress Ecommerce Themes with Shopping Cart
  • OpenCart as a favorite E-Commerce Application and Its Templates

If you are using this plugin as an e-Commerce platform and want to add multiple categories, here give you a solution for that and by using this code you can create your own Plugin to add bulk Product categories for your online shop. You can read all about WP-eCommerce Plugin here: Create Online Store with Free WordPress e-Commerce plugin

<?php
/*
Plugin Name: Add Product Categories
Version: v0.1
Author: WordPress Arena
URL: https://wparena.com
Description: Bulk category import for WP-eCommerce Plugin
Plugin URI: https://wparena.com/?p=10921
Author URI: https://wparena.com
*/
function batch_import_function() {
global $wpdb;
if(isset($_POST['Add'])) {

$group_id = $_POST['groupid'];
$parent_id = $_POST['category'];
$categories = $_POST['categories'];
$cats_array = explode(",",$categories);
print_r ($cats_array);
foreach($cats_array as $key => $value) {
$nice_name = str_replace (" ","-",$value);
echo ($nice_name);
$wpdb->insert(
	'wp_wpsc_product_categories',
	array(
		'group_id' => $group_id,
		'name' => $value,
		'nice-name' => $nice_name,
		'active' => 1,
		'category_parent' => $parent_id
		),
	array(
		'%s',
		'%s',
		'%s',
		'%d',
		'%d'
	)
);
}
  }
?>
<form name="batchcats" action="" method="post">
Group:<input type="text" name="groupid" />
Parent Category:<input type="text" name="category" />
Categories:<textarea name="categories"></textarea>
<input name="Add" type="submit" value="Add" />
</form>
<?php
}
function batch_import() {
      add_menu_page("Import Categories", "Import Categories", 1, "Import Categories", "batch_import_function");
}
add_action('admin_menu', 'batch_import');
?>

Save this file as a .php and upload it into plugin directory, activate the plugin and you will see “Import Categories” tab in your admin panel. Click on this tab and add Group id number and add Parent Category id, after adding ids entry the categories name separated by commas and click on add button.

WordPress Themes for eCommerce

  • Gorilla Themes
  • iTheme Builder
  • Genesis Theme Framework
  • DIY Themes
  • StudioPress
  • Elegant Themes
  • MOJO Themes
  • ThemeForest
This post was orginally published on: September 19, 2011 and was updated on: October 12, 2020.

Related Tags: eCommerce Shopping Cart

FacebookTweetPinLinkedInEmailPrint

Related Stories

  • How To Edit WordPress Links CSS and Modify Them (The a tag)

    How To Edit WordPress Links CSS and Modify Them (The a tag)

  • How to Build a Charity Site using WordPress

    How to Build a Charity Site using WordPress

  • How To Keep Your eCommerce Company on Message

    How To Keep Your eCommerce Company on Message

Avatar of Noor Mustafa Raza

Noor Mustafa Raza

Ex-Editor in chief

I am a WordPress Developer and Designer, author @WPArena. I am providing Free WordPress consultation and can help you to install WordPress in a secure way to small businesses and bloggers.

Reader Interactions

Share Your Thoughts Cancel reply

Before submitting your comment, we kindly ask that you read our comment policy. Your email address will remain confidential and will not be published or shared anywhere. If you subscribe, you will receive notifications regarding new comments.

Primary Sidebar

Inspect WordPress Using Zend Server Z-Ray

42+ Most Common Blogging Mistakes

Recent Topics

  • Official Windows 7 Wallpapers
  • How to secure your WordPress images and content from Theft
  • Top 20 Web Designing Companies in the World
  • WP Rocket Review: Is It the Perfect Solution for WordPress Caching?
  • The Complete WordPress Security Guide 2023 – Step by Step

Footer

Top

  • Services
  • Our Themes
  • Facebook
  • Twitter
  • Linkedin

Reviews

  • Beaver Builder Review
  • Beaver Themer Review
  • WP User Frontend Pro
  • Ninja Forms Review
  • MemberPress Review

More Reviews »

Resources

  • Best WordPress Plugins
  • WordPress Permalinks Structure
  • Email Management System
  • Envato Free Files
  • Advertise
  • Write for us
  • Disclosure
  • Terms
  • Privacy
  • Contact

Copyright © 2023 · All Rights Reserved · WPArena is a Project of TechAbout LLC.
We are not affiliated with Automattic or WordPress.

  • Advertise
  • Write for us
  • Disclosure
  • Terms
  • Privacy
  • Contact
Share this ArticleLike this article? Email it to a friend!

Email sent!