WooCommerce Code Snippets to Customise Your Store

Customise a WooCommerce store without extra plugins: a currency word instead of the symbol, a minimum order, a free shipping notice, a shorter checkout, Saudi mobile validation and more. Pick what you need and get a ready small plugin file.

Pick snippets

Snippets

Pick snippets

Settings

Why snippets instead of plugins?

One plugin per small tweak

Dozens of plugins slow the store Each one brings updates and possible holes

One snippets file

A few lines per tweak Works with any theme and cannot be deactivated by mistake

Classic checkout or the Checkout block?

New WooCommerce stores use the Checkout block from the block editor, and some cart and checkout snippets (marked Heads-up) are written for the classic page and may not work with the block. To check yours, edit the page: if you see the [woocommerce_checkout] shortcode, it is classic.

SnippetWorks in
Currency, button text, auto-complete, related products, reviewsAll stores
Minimum order, fields, postcode, phone, shipping noticeThe classic page for sure; test it with the Checkout block

Functions worth knowing in WooCommerce

CartWC()->cart->get_subtotal()
Checkout URLwc_get_checkout_url()
Price formatwc_price( 100 )
WP-CLIwp wc product list --user=1

If your store needs more resources, size it with the WordPress resource calculator, and for general site code try WordPress snippets.

Example: a perfume store with a minimum and free shipping

Pick “Minimum order amount” at 100 SAR and the free shipping notice at 300 SAR, and enable free shipping in shipping settings at the same amount. Customers see in the cart how much is left and add another item instead of paying for shipping.

Key terms

Short definitions of what you meet along the way.

Hook
A point in WooCommerce code where you add your own code without editing plugin files.
Checkout block
The new checkout page built with the block editor, instead of the old shortcode.
wc_price
A function that shows an amount in the store currency and format.

Frequently asked questions

Did not find your answer? Ask us on WhatsApp

Where do I put the code?

Best as a file in wp-content/mu-plugins that works with any theme, or at the end of a child theme functions.php.

The code has no effect on my checkout page?

Your page may use the new Checkout block, and some snippets are written for the classic page. See the table above.

Are the snippets safe for my store?

They use official WooCommerce functions and filters. Add one at a time after a backup, and read the note on any snippet marked Heads-up.

How do I undo a snippet?

Delete the file from mu-plugins or remove its lines, and the store goes back to how it was.

A fast, stable WooCommerce store?

WordPress hosting tuned for stores, with daily backups, Arabic support and free migration of your store.

Contact us on WhatsApp