Snippets for Classic Commerce

I have set up an area on the Classic Commerce website to start listing useful code snippets for Classic Commerce.

These are small pieces of code that add minor functionality without the need for extra plugins. They can be used in either the functions.php file in a child theme, or in a utility plugin that you have created specifically for that purpose.

The idea is similar to the one currently available on the WooCommerce docs…

If you have a code snippet that you find useful in CC/WC then post it here and I will add it. Please include a sentence or two about what the snippet does and why it is useful.


This is fantastic!
The official site is very good, looked it over last night. Also, took Classic Commerce for a test spin on a staging site - very fast and very impressed!

I do indeed have useful code snippets for WooCommerce. I will pass them on and you can adapt them for CP and CC functionality.

Keep up the good work! :clap:

( Just sent you a message of the WC snippets we use, so you can choose and share. )



Hey, thanks Avrom. I’m still tweaking the site but I think it’s getting closer. And great to hear that CC is working well for you.

Thanks also for those code snippets. I’ll go through them and add some to the site.


Your snippet to add the prefix to the $ sign is brilliant (US$, AU$, CA$, etc). I’m surprised that doesn’t come as a fundamental part of WC/CC. Seems like an obvious requirement for any shop selling to multiple countries.

Might be worth adding that as an enhancement request in GitHub.

(also like the redirect shop page one… that’s useful)


Hi Alan,
I’d like to take credit for the currency code, but it was taken from the web. I found lots of developers using that same code snippet. So why write it from scratch?
The only issue I have with it, is it places the currency prefix everywhere. It would be nicer if it was just for subtotals and totals.

The reason it isn’t added to WooCommerce by default, is they can’t up-sell plugins. :wink:


1 Like

Hey, that’s the same place I get all my code. :wink:


I’ve been looking around the net and finding lots of useful snippets to add to the Classic Commerce collection here:

The list is currently up to 75! (not bad, considering WooCommerce has a mere 61 on their site :wink:)

They’ve all been tested as working with Classic Commerce on ClassicPress, so if anyone finds any problems with anything please post here.


I’ve been putting an extension together for Classic Commerce and that’s going to be an awesome reference point - thank you for putting it together, that is a massive effort right there :+1:

If anyone testing out Classic Commerce would like to check the extension out and take it for a spin then it can be found here > Extend Commerce - just a few functions at the moment but it’s bound to grow. And apologies for lack of documentation but will get to it as soon as I can.


So this is going to be a plugin that is a collection of useful functions? That’ll be good.

It was actually a really useful exercise for me to find these snippets, learn what they did and test them out. Found a lot of stuff that I can use.

1 Like

Yes very much so. Plus some new ones as Classic Commerce evolves and branches off in a new directions(a personal wish to see new functionality not present in WC) :slight_smile:


Someone asked me about hiding SKUs and I didn’t see this on the list, here they are:

Disable SKUs completely

add_filter('wc_product_sku_enabled', '__return_false');

Hide SKUs in the frontend but keep them in the backend

function pa_hide_skus($enabled){
	if(!is_admin() && is_product()){
		return false;
	return $enabled;
add_filter('wc_product_sku_enabled', 'pa_hide_skus');

Thanks Viktor. I’ll add that in.