Snippets for Classic Commerce

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

https://classiccommerce.cc/docs/snippets/

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…
https://docs.woocommerce.com/documentation/plugins/woocommerce/woocommerce-codex/snippets/

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.

8 Likes

This is fantastic!
The official classiccommerce.cc 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:

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

Cheers
Avrom

5 Likes

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.

4 Likes

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)

2 Likes

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:

Cheers
Avrom

1 Like

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

4 Likes