Extending Products

Introduction

The default product model that wpStoreCart uses is not appropriate for all businesses and websites. Fortunately, using wpStoreCart Action Hooks, you can extend the capabilities of products in any way imaginable, both in the admin panel, and to the customers. This document will provide a brief overview of how any intermediate PHP/Wordpress developer, can extend the wpStoreCart product system.

Quick Overview

Programming Skill: Intermediate & above
Skills Needed: PHP, HTML, WordPress Hooks & Filters

Initial Product Editing Hooks

wpStoreCart v3.0.14 & above.
wpsc_admin_edit_product_top The first action hook called in this context. The product key you are editing will be in the $_GET['keytoedit'] variable.
wpsc_admin_edit_product_loading This hook is called directly after attempting to load the data for $_GET['keytoedit']
wpsc_admin_edit_product_js A hook for implementing custom javascript. If you tie a function to wpsc_admin_edit_product_js then the function should echo out javascript only.

Hooks for Adding New Tabs

wpStoreCart v3.0.14 & above.
wpsc_admin_edit_product_tab_header A hook for implementing custom javascript. If you tie a function to wpsc_admin_edit_product_tab_header then the function should echo out a li tag in this format:

echo '<li>
   <a href="#tab_custom1">
     <img src="'.plugins_url() . '/wpstorecart/images/cart_put.png" /> 
     Custom Tabname
   </a>
</li>';
wpsc_admin_edit_product_tab_contents Use this, in conjunction with the wpsc_admin_edit_product_tab_header hook, to create a new tab. This particular hook should echo out a DIV with the actual contents of your new tab. The tab ID should be identical to href location specified in the a tag you created with the wpsc_admin_edit_product_tab_header hook.

Hooks for Adding Content to Existing Tabs In New Rows

Product Tab

wpStoreCart v3.0.14 & above.
wpsc_admin_edit_product_table_before_product_name A hook inside of an HTML table, directly before the Product Name table row. For this, and other wpsc_admin_edit_product_table_before_* hooks, remember that you are already within a form, so do not use the form tag, and also remember to echo out a table row in this format:

echo '
<tr>
    <td><p>Descriptive Name</p></td>
    <td>Main content you are adding, like inputs. No form elements are allowed.</td>
</tr>';
wpsc_admin_edit_product_table_before_product_intro A hook inside of an HTML table, directly before the Product Intro Description table row.
wpsc_admin_edit_product_table_before_product_description A hook inside of an HTML table, directly before the Product Full Description table row.
wpsc_admin_edit_product_table_before_product_price A hook inside of an HTML table, directly before the Product Price table row.
wpsc_admin_edit_product_table_before_product_inventory A hook inside of an HTML table, directly before the Product Inventory table row.
wpsc_admin_edit_product_table_before_product_category A hook inside of an HTML table, directly before the Product Category table row.
wpsc_admin_edit_product_table_before_product_downloads A hook inside of an HTML table, directly before the Product Download table row.
wpsc_admin_edit_product_table_before_product_thumbnail A hook inside of an HTML table, directly before the Product Thumbnail table row.
wpsc_admin_edit_product_table_after_product_thumbnail A hook inside of an HTML table, directly after the Product Thumbnail table row, but before the table tag is closed.

Hooks for Adding Content to Existing Tabs In Existing Rows

Coming Soon

Saving Product Hook

Chances are, if you are creating additional product admin panel options, you’re also going to want to be able to save data. Of course, you could implement your own ajax calls to save your data, but we recommend waiting for the admin user to hit the “Save Product” button, and to use the wpsc_admin_save_product() hook to save your data there.

wpStoreCart v3.0.14 & above.
wpsc_admin_save_product Hook called when saving a product. Product data is transferred using POST, meaning your code should also work with POST data. The product key is pre-santitized and is available in this variable: $_POST['wpsc-keytoedit']

Filters For Product Pages & Shortcodes

While the previous action hooks all dealt with adding additional admin panels for creating and editing products, the next items are filters for adding manipulating and adding new content when the product is displayed on it’s page. All of these filters are available both in the product’s page, as well as any product display shortcode that is used to display the product. This set of filters was initially created in wpStoreCart 3.0.15, so you will need that version or higher to use these them.

Remember, most items on the product page can be arranged in any way the admin wishes. This also means that your filters may be displayed nearly anywhere on the page. For example, if you displayed something using the wpsc_display_product_before_thumbnail() hook, your content would always display directly before the thumbnail. However, the thumbnail itself may be positioned at the bottom of the product page, at the top, or anywhere else the admin decides.

wpStoreCart v3.0.15 & above. Note that when using these filters, if you declare $wpsc_results as global inside your function, you can access the product’s data in this format $wpsc_results[0]['primkey'], $wpsc_results[0]['introdescription'] etc.
wpsc_display_product_start A filter that expects you to return a string. The returned string is displayed directly underneath the <div class=”wpsc-single-product”>
wpsc_display_product_end A filter that expects you to return a string. The returned string is displayed directly before the .wpsc-single-product DIV is closed.
wpsc_display_product_before_thumbnail A filter that expects you to return a string. The returned string is displayed directly before the products thumbnail, directly after the <div class=”wpscsort_1″>
wpsc_display_product_after_thumbnail A filter that expects you to return a string. The returned string is displayed directly after the products thumbnail, directly before the wpscsort_1 DIV is closed.
wpsc_display_product_before_addtocart A filter that expects you to return a string. The returned string is displayed directly before the products add to cart button, directly after the <div class=”wpscsort_3″>
wpsc_display_product_after_addtocart A filter that expects you to return a string. The returned string is displayed directly after the products add to cart button, directly before the wpscsort_3 DIV is closed.
wpsc_display_product_before_picture_gallery A filter that expects you to return a string. The returned string is displayed directly before the products picture gallery, directly after the <div class=”wpscsort_4″>
wpsc_display_product_after_picture_gallery A filter that expects you to return a string. The returned string is displayed directly after the products picture gallery, directly before the wpscsort_4 DIV is closed.
wpsc_display_product_before_single_intro A filter that expects you to return a string. The returned string is displayed directly before the products intro description, directly after the <div class=”wpscsort_5″>
wpsc_display_product_after_single_intro A filter that expects you to return a string. The returned string is displayed directly after the products intro description, directly before the wpscsort_5 DIV is closed.
wpsc_display_product_before_single_description A filter that expects you to return a string. The returned string is displayed directly before the products description, directly after the <div class=”wpscsort_6″>
wpsc_display_product_after_single_description A filter that expects you to return a string. The returned string is displayed directly after the products description, directly before the wpscsort_6 DIV is closed.
wpsc_display_product_before_accessories A filter that expects you to return a string. The returned string is displayed directly before the products accessories, directly after the <div class=”wpscsort_7″>
wpsc_display_product_after_accessories A filter that expects you to return a string. The returned string is displayed directly after the products accessories, directly before the wpscsort_7 DIV is closed.

Filters For Product Catalog

wpStoreCart v3.1.2 & above. if you declare $wpsc_result as global inside your function, you can access the current product’s data in this format $wpsc_result['primkey'], $wpsc_result['introdescription'] etc.
wpsc_display_catalog_start A filter that expects you to return a string. The returned string is displayed directly before each product in the catalog.
wpsc_display_catalog_end A filter that expects you to return a string. The returned string is displayed directly after each product in the catalog.
wpsc_display_catalog_before_thumbnail A filter that expects you to return a string. The returned string is displayed directly before each products thumbnail, directly after the wpscsort_1 DIV
wpsc_display_catalog_after_thumbnail A filter that expects you to return a string. The returned string is displayed directly after each products thumbnail, directly before the wpscsort_1 DIV is closed.
wpsc_display_catalog_before_title A filter that expects you to return a string. The returned string is displayed directly before each products title, directly after the wpscsort_2 DIV
wpsc_display_catalog_after_title A filter that expects you to return a string. The returned string is displayed directly after each products title, directly before the wpscsort_2 DIV is closed.
wpsc_display_catalog_before_intro A filter that expects you to return a string. The returned string is displayed directly before the products intro description, directly after the wpscsort_3 DIV
wpsc_display_catalog_after_intro A filter that expects you to return a string. The returned string is displayed directly after the intro description, directly before the wpscsort_3 DIV is closed.
wpsc_display_catalog_before_description A filter that expects you to return a string. The returned string is displayed directly before the products description, directly after the wpscsort_4 DIV
wpsc_display_catalog_after_description A filter that expects you to return a string. The returned string is displayed directly after the description, directly before the wpscsort_4 DIV is closed.
wpsc_display_catalog_before_price A filter that expects you to return a string. The returned string is displayed directly before the products price, directly after the wpscsort_5 DIV
wpsc_display_catalog_after_price A filter that expects you to return a string. The returned string is displayed directly after the price, directly before the wpscsort_5 DIV is closed.
wpsc_display_catalog_before_addtocart A filter that expects you to return a string. The returned string is displayed directly before the products add to cart button, directly after the wpscsort_6 DIV
wpsc_display_catalog_after_addtocart A filter that expects you to return a string. The returned string is displayed directly after the add to cart button, directly before the More Info button.
wpsc_display_catalog_before_moreinfo A filter that expects you to return a string. The returned string is displayed directly before the products more info button, directly after the add to cart button.
wpsc_display_catalog_after_moreinfo A filter that expects you to return a string. The returned string is displayed directly after the add to cart button, directly before the wpscsort_6 DIV.