Archive for the ‘Ecommerce’ category

SB Add WooCommerce Tabs – WordPress Plugin

March 30th, 2013

You have been asking for this so I wrote it for you. This plugin is a very simply way of adding a WYSIWYG controlled tab to your WooCommerce products. It does the legwork for you and all you need to do it edit 1 line in the plugin file to set the tab name and to determine how many tabs you want. I have even provided examples for you in the code.

I might eventually add a little admin system to this but for now you get the following:

$sb_awt_tabs = array(
    'New Tab 1'=>50
    , 'New Tab 2'=>60
    // , 'New Tab 3'=>50
    // , 'New Tab 4'=>50
);

You wil note two tabs are uncommented and two are commented. Simply change the part at the start for the name and the second part is the priority. Very simply put the higher the number the further right in your tab list it will be. If you need more than 4 tabs then simply duplicate a line as normal.

Once you activate the plugin you will notice a new Tiny MCE editor at the bottom of each edit products page. Simply fill it in if you want the tab to show or leave it blank to hide the tab. Nice and easy!

I should add that if you include any shortcodes in the tab editor then they will be read also.. ie a YouTube video or something.

Download

SB Add WooCommerce Tabs (1.26 kB)

Note

This plugin only works with WooCommerce Version 2 or newer. I have already written another post last year to show you how to add new tabs to older versions.

How to remove the WooCommerce 2.0+ Reviews tab

March 7th, 2013

woothemes-ninja3On the 6th of March (I think) the lovely guys at WooThemes graced us with a lovely new version of their fantastic WooCommerce plugin. They changed a lot of things, most of which I have yet to absorb. A couple of notable things though caught my eye. You may or may not be aware that I have written a few tutorials concerning the WooCommerce tab system. Adding new ones and, of course, removing the reviews tab. Since 2.0 the product tab API has been updated and is now somewhat slightly more elegant. » Read more: How to remove the WooCommerce 2.0+ Reviews tab

Adding your own WooCommerce Tabs simplified step by step

November 5th, 2012

woocommerce_logoMy original tutorial on WooCommerce product tab addition has gone down very well. However it has been brought to my attention that people who don’t know much PHP are struggling to follow it. This is ok.. we all need to start somewhere but for convenience I have put it all into a plugin and commented each line with instructions accordingly. The content of that plugin is directly pasted below with a download link at the bottom for you. It will work out of the box with no modification. You just need to add a custom field to your products which have additional information. If anyone is interested I shall write another tutorial on how to add a nice WYSIWYG editor to the product admin pages for that more integrated feel.

» Read more: Adding your own WooCommerce Tabs simplified step by step

WooCommerce Interswitch WebPay WordPress Plugin

October 24th, 2012

I have recently integrated the Interswitch WebPay payment gateway into the popular WooCommerce plugin for WordPress. It sends the user off to Interswitch to enter their payment information as normal. Then they return to the site with their information in POST it sends a CURL request to the Interswitch server which returns the payment status. If the status is positive then the order is set to Processed and the purchase process completed pending dispatch of the item(s). Id the CURL request returns an error then the message is presented to the user in conjunction with a ‘try again’ link which sends them off to Interswitch to enter their information again as per the requirements set out by Interswitch.

I opted to use the CURL method (relatively undocumented) of sale authentication because the SOAP Web service method (equally badly documented) wasn’t functioning on the client server at the time due to SOAP not being enabled. I presume that SOAP might not be available to a number of site owners and to avoid having them jump hoops in order to use the gateway CURL seemed sensible.

Any suggestiona for this plugin are welcome. A download link is below although I shall also be hosting it on the WordPress Plugin Directory and hopefully listed on the Woothemes.com site in their third party plugins section.

Download

Download available via the WordPress Repository by clicking here

WooCommerce removing the reviews tab

May 15th, 2012

UPDATE: If you are using WooCommerce 2.0+ then you need to read this blog post I wrote instead which explains the ‘new’ system for you.

Another quickie from me today. I have been using WooCommerce a lot recently but there are just some options that could do with making into options or filters I think. As I understand it’s a JigoShop rebadge with a bit of Woo goodness in there for luck and it seems to be paying off. I never want to use WP Ecommerce again at this rate.

Each WooCommerce installation will have the reviews tabs added to individual product pages. As I understand it it uses the WordPress comment system to hold review information (so says one forum, i’ve not bothered to check it out). I noted that people are wanting to know how to turn this functionality off as reviews don’t really apply to all products in all shops. Adding this code to your theme functions.php file will remove the reviews tab. If you want it back then just remove the lines.. simples.

remove_action( 'woocommerce_product_tabs', 'woocommerce_product_reviews_tab', 30);
remove_action( 'woocommerce_product_tab_panels', 'woocommerce_product_reviews_panel', 30);

Edit:

People have asked how to remove the product attributes tab and the additional description tab also. You can do so using the following code:
remove_action( 'woocommerce_product_tabs', 'woocommerce_product_description_tab', 10);
remove_action( 'woocommerce_product_tab_panels', 'woocommerce_product_description_panel', 10);
remove_action( 'woocommerce_product_tabs', 'woocommerce_product_attributes_tab', 20);
remove_action( 'woocommerce_product_tab_panels', 'woocommerce_product_attributes_panel', 20);

Also see my new tutorial in how to add a new tab to the WooCommerce product pages

Editing WooCommerce default product column count

May 13th, 2012

You know it’s the little things in life that highlight our great successes. I have been looking for this for literally hours.. What I wanted to do was edit the number of product columns that are shown in the default grid view homepage. It’s set to 4 and I wanted 3. Not hard right? Sadly it was but the solution was a two liner! Let me explain…

Woocommerce, by default, doesn’t work from a shortcode (it can do but not by default), instead it will show the shop page content using it’s own template system. It will look for arguments/parameters attached to the shortcode in order to augment the number of columns on any product listing page. I know I know, I just said that we aren’t using a shortcode but it’s looking for one anyway? Almost.. here is the solution:

global $woocommerce_loop;
$woocommerce_loop['columns'] = 3;

There we have it, two lines. Either a sign of my genius or incompetence. I suspect the latter but for the moment I am fairly proud of this achievement. Essentially $woocommerce_loop contains the settings for the product page and by default the columns argument isn’t set leaving it up to the shortcode to populate (if used) or to fall back to it’s standard setting.. 4!

So after hours of trawling through code trying to find a WordPress Filter I can hook onto, I thought I would try this little gem (added to my theme functions.php) and magically it worked. This post can now hopefully help the next person to have to deal with this or indeed for someone to point out my stupidity and show me how it should have been done.

WooCommerce featured products slider automatic cycling

May 2nd, 2012

I have just spent a few hours looking at the dire attempts at making a product slider for WooCommerce. In the end I decided I couldn’t justify even $12 for a premium ‘effort’ on account of it being a bit dire. It seems these days people will cough up for things just because they are paid for on the assumption that because they had to part with some of their hard earned it’s going to be any good. Anyway moving on…

I found the fabulous Wootique theme that is offered as the general purpose theme from WooThemes contains a featured products flipper at the top as an option. It looks great and works with WooCommerce already so why not just make that autocycle? So I did…

Wootique Featured product flipper

The following block of Javascript/jQuery will cause the slider to cycle on every two seconds and when it gets to the end it will reverse direction and start in the opposite direction. Rinse and repeat…

I also added some code to detect when your mouse is hovering over the slider to pause it so it doesn’t carry on sliding whilst you are reading or studying one of the product images.

I shall make the entire thing into a plugin at some point but for now this works beautifully with Wootique or any Woo Theme with the same flipper at the top.

The Code

var hoverpause = 0;

jQuery(document).ready(function () {
    sb_timed_cycle('next');

    jQuery('#featured-products .jcarousel-container').hover(
	function () { hoverpause = 1; },
	function () { hoverpause = 0; }
    );
});

function sb_timed_cycle(direction) {
    setTimeout( function() {
	if (!hoverpause) {
	    if (direction == 'next') {
		if (jQuery('#featured-products .jcarousel-next').attr('disabled') != 'disabled') {
		    jQuery('#featured-products .jcarousel-next').click();
		} else {
		    direction = 'prev';
		    jQuery('#featured-products .jcarousel-prev').click();
		}
	    } else {
		if (jQuery('#featured-products .jcarousel-prev').attr('disabled') != 'disabled') {
		    jQuery('#featured-products .jcarousel-prev').click();
		} else {
		    direction = 'next';
		    jQuery('#featured-products .jcarousel-next').click();
		}
	    }
	}
	sb_timed_cycle(direction);
    }, 2000 );
}

The File
I have written this into a simple, just activate, type plugin for those that prefer this to theme integration. SB Woo Slider Auto Cycle (701 bytes)

WP Ecommerce custom email content

March 6th, 2012

The WP Ecommerce system itself is a huge pain in the backside to use and work at times as we all know but a nice saving grace is that the plugin has a huge range of hooks and filters which we, as developers, can write plugins and blocks of code to extend.

My latest issue has been the checkout fields system. I am told by one of their staff that it’s due a rewrite in future versions however for those using older versions… You might notice that it’s not the simplest system in the world. Don’t get me wrong it’s my shopping cart of choice but I think there are a few areas where a little work could polish it up nicely. Checkout fields define what questions are asked of the buyer on the checkout page. Default values include their billing and shipping address but it’s not uncommon to want to add fields of our own to that like newsletter signup for instance. A project I am working on at the moment has a pickup point field present which we want to add to the user or admin emails. The ‘shortcodes’ provided are limited but luckily the filter ‘wpsc_transaction_result_message’ (and a couple of others) allows us to hook into it and run our own code as follows:

add_filter('wpsc_transaction_result_message', 'sb_transaction_results_custom_fields');
add_filter('wpsc_transaction_result_report', 'sb_transaction_results_custom_fields');
add_filter('wpsc_transaction_result_message_html', 'sb_transaction_results_custom_fields_html');

function sb_transaction_results_custom_fields_html($message) {
return sb_transaction_results_custom_fields($message, true);
}

function sb_transaction_results_custom_fields($message, $html=false) {
$values = array();

foreach ($_SESSION['wpsc_checkout_saved_values'] as $key=>$value) {
if ($value) {
if (is_array($value)) {
$value = implode(', ', $value);
}

$values[] = $key . ': ' . $value;
}
}

$message = str_replace('%custom_fields%', implode(($html ? '<br />':"\n"), $values), $message);

return $message;
}

These functions will replace the new shortcode %custom_fields% with the entire contents of the checkout form. It’s not pretty in this form which is why we should use the ID and then reference the field name in the database when making it into a plugin. I might do at some point but for now it’s a handy little bit of reference code for people to work with. I am happy to explain more if anyone if interested.