- Dessky.com

wc_clean – WooCommerce Core Function

December 4, 2021 in Code Snippets

The following useful function is found in the includes/wc-core-functions.php and can be used by themes and plugins. Trims and strips tags from a string ($var). wc_clean( $var )

Read More →

Disable the default stylesheet in WooCommerce

December 1, 2021 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. Disable all stylesheets WooCommerce enqueues 3 […]

Read More →

Change the default state and country on the checkout in WooCommerce

November 25, 2021 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Change the default state […]

Read More →

Add a custom currency symbol in WooCommerce

November 4, 2021 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Custom currency and currency […]

Read More →

Retrieving a customer in WooCommerce

October 13, 2021 in Code Snippets

$customer = new WC_Customer( $user_id ); $email = $customer->get_email(); $address = $customer->get_billing_address(); $name = $customer->get_first_name() . ' ' . $customer->get_last_name();

Read More →

Exclude products from a particular category on the shop page in WooCommerce

October 5, 2021 in Code Snippets

As ‘clothing’ is an example in the snippet below, be sure to use a product category slug that exists in your WooCommerce store. Note that this will only work when you have your “Shop Page Display” option set to ‘Show Products’ under your Customizers’ WooCommerce > Product catalog settings. Add this code to your child […]

Read More →

WooCommerce payment gateway plugin base

September 30, 2021 in Code Snippets

This code can be used as a base to create your own simple custom payment gateway for WooCommerce. Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php […]

Read More →

Adding a Custom Special Field in WooCommerce

September 4, 2021 in Code Snippets

Let’s add a new field to checkout, after the order notes, by hooking into the following. /** * Add the field to the checkout */ add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' ); function my_custom_checkout_field( $checkout ) { echo '<div id="my_custom_checkout_field"><h2>' . __('My Field') . '</h2>'; woocommerce_form_field( 'my_field_name', array( 'type' => 'text', 'class' => array('my-field-class form-row-wide'), 'label' => __('Fill […]

Read More →

Make phone number not required in WooCommerce

July 7, 2021 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. add_filter( 'woocommerce_billing_fields', 'wc_npr_filter_phone', 10, 1 ); […]

Read More →

Show product categories in WooCommerce breadcrumbs

June 5, 2021 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Show product categories in […]

Read More →

Declaring WooCommerce Support

May 9, 2021 in Code Snippets

function mytheme_add_woocommerce_support() { add_theme_support( 'woocommerce' ); } add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );

Read More →

Hide loop read more buttons for out of stock items in WooCommerce

May 3, 2021 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Hide loop read more […]

Read More →

wc_get_weight – WooCommerce Core Function

May 2, 2021 in Code Snippets

The following useful function is found in the includes/wc-core-functions.php and can be used by themes and plugins. Takes a weight ($weight) weighed in WooCommerce’s weight unit and converts it to the target weight unit ($to_unit). wc_get_weight( 10, 'lbs' )

Read More →

Customize the WooCommerce breadcrumb

April 23, 2021 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. Useful if you want to change […]

Read More →

Register the taxonomy for menus in WooCommerce

April 7, 2021 in Code Snippets

When registering taxonomies for your custom attributes, WooCommerce calls the following hook: $show_in_nav_menus = apply_filters('woocommerce_attribute_show_in_nav_menus', false, $name); So, for example, if your attribute slug was ‘size’ you would do the following to register it for menus: add_filter('woocommerce_attribute_show_in_nav_menus', 'wc_reg_for_menus', 1, 2); function wc_reg_for_menus( $register, $name = '' ) { if ( $name == 'pa_size' ) $register […]

Read More →

Check if both the billing and the shipping address contain a house number in WooCommerce

March 13, 2021 in Code Snippets

Currently, when using the Checkout block from the WooCommerce Blocks plugin, there’s no check if the billing or shipping address field contains a house number. The following code snippets allow to check if these fields contain a number. To check if both the billing and the shipping address contain a house number, please use the […]

Read More →

Unhook the WooCommerce wrappers

March 11, 2021 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); remove_action( 'woocommerce_after_main_content', […]

Read More →

Example products loop in WooCommerce

March 5, 2021 in Code Snippets

<ul class="products"> <?php $args = array( 'post_type' => 'product', 'posts_per_page' => 12 ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); wc_get_template_part( 'content', 'product' ); endwhile; } else { echo __( 'No products found' ); } wp_reset_postdata(); ?> </ul><!–/.products–>

Read More →

Query whether WooCommerce is activated

February 17, 2021 in Code Snippets

If you’re building a theme which supports but doesn’t require WooCommerce, you may want to wrap WooCommerce functionality (think cart links etc) inside a conditional query. That way, if WooCommerce isn’t activated, the functionality is simply ignored instead of producing fatal errors. Add this code to your child theme’s functions.php file or via a plugin […]

Read More →

Minimum Order Amount in WooCommerce

January 15, 2021 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Set a minimum order […]

Read More →

Allow shortcodes in product excerpts in WooCommerce

December 28, 2020 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Allow shortcodes in product […]

Read More →

Using the New Settings in WooCommerce

December 27, 2020 in Code Snippets

You would now just use your newly created settings like you would any other WordPress / WooCommerce setting, through the get_option function and the defined ID of the setting. For example, to use the wcslider_auto_insert option from previous snippet, simply use the following code. get_option( 'wcslider_auto_insert' );

Read More →

Send coupons used in an order by email in WooCommerce

December 5, 2020 in Code Snippets

This snippet sends by email the list of coupons used in an order. You can customize the $to variable and define your own email address, and the $message to have your own text. Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as […]

Read More →

Change Limit on Number of Variations for Dynamic Variable Product Dropdowns in WooCommerce

October 5, 2020 in Code Snippets

By default, if a Variable product has fewer than 30 variations, the dropdowns for selecting variations on the frontend will be dynamic. For example, with a T-shirt that has “Size” and “Color” attributes, after the customer selects a Size, the Color dropdown will be updated via AJAX to only display options that are available with […]

Read More →

Add your own stylesheet in WooCommerce

September 2, 2020 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. Enqueue your own stylesheet like this: […]

Read More →

How to Add Settings to a Section in WooCommerce

August 18, 2020 in Code Snippets

You need to filter the output of woocommerce_get_sections_products (or similar). For example, let’s add the sample settings we discussed above to the new wcslider section we just created. /** * Add settings to the specific section we created before */ add_filter( 'woocommerce_get_settings_products', 'wcslider_all_settings', 10, 2 ); function wcslider_all_settings( $settings, $current_section ) { /** * Check […]

Read More →

Override loop template and show quantities next to add to cart buttons in WooCommerce

August 16, 2020 in Code Snippets

To display quantity input fields for simple products within your shop archive pages, use the following code. /** * Override loop template and show quantities next to add to cart buttons */ add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 ); function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) { if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() […]

Read More →

Automatically add product to cart on visit in WooCommerce

August 9, 2020 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Automatically add product to […]

Read More →

Apply a coupon for minimum cart total in WooCommerce

July 31, 2020 in Code Snippets

The code snippet below allows you to: Show a notice on the cart and checkout page, reminding customers that they get a discount if spending more than a minimum amount. Automatically apply a discount and show a notice that the discount was applied when the cart total is more than a minimum amount. Add this […]

Read More →

Add a new country to countries list in WooCommerce

July 30, 2020 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Add a new country […]

Read More →

Removing Tabs in WooCommerce

July 17, 2020 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. Use the following snippet to remove […]

Read More →

Change number of products per row in WooCommerce

June 28, 2020 in Code Snippets

Defines where ‘first’ and ‘last’ classes are applied in product archives. Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely […]

Read More →

Add checkout validation styles to a custom theme in WooCommerce

June 15, 2020 in Code Snippets

You need to add this CSS to your child theme’s style.css file or to your customizers’ “Additional CSS” section. Please don’t add custom code directly to your parent theme’s style.css file as this will be wiped entirely when you update the theme. .form-row.woocommerce-invalid .chzn-single, .form-row.woocommerce-invalid .chzn-drop, .form-row.woocommerce-invalid input.input-text, .form-row.woocommerce-invalid select { border:1px solid red; } […]

Read More →

Hide sub-category product count in WooCommerce product archives

June 10, 2020 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Hide category product count […]

Read More →

Using action hooks in WooCommerce

June 1, 2020 in Code Snippets

To execute your own code, you hook in by using the action hook do_action(‘action_name’);. Here is where to place your code: add_action( 'action_name', 'your_function_name' ); function your_function_name() { // Your code }

Read More →

Remove product content based on category in WooCommerce

May 20, 2020 in Code Snippets

The following code will remove product images on single product pages within the ‘Cookware’ category. Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this […]

Read More →

Updating an existing coupon in WooCommerce

April 22, 2020 in Code Snippets

$coupon = new WC_Coupon( $coupon_id ); $coupon->set_discount_type( 'percent' ); $coupon->set_amount( 25.00 ); $coupon->save();

Read More →

Display product attribute archive links in WooCommerce

March 18, 2020 in Code Snippets

Display WooCommerce product attribute archive links on the product page, right below the add to cart button. Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file […]

Read More →

Check if the shipping address contains a house number in WooCommerce

March 12, 2020 in Code Snippets

Currently, when using the Checkout block from the WooCommerce Blocks plugin, there’s no check if the billing or shipping address field contains a house number. The following code snippets allow to check if these fields contain a number. To check if the shipping address contains a house number, please use the following code snippet: add_action( […]

Read More →

Customizing checkout fields using actions and filters in WooCommerce

March 11, 2020 in Code Snippets

Let us change the placeholder on the order_comments fields. We can change this by adding a function to our theme functions.php file: // Hook in add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ); // Our hooked in function – $fields is passed via the filter! function custom_override_checkout_fields( $fields ) { $fields['order']['order_comments']['placeholder'] = 'My new placeholder'; return $fields; } […]

Read More →

Add a custom tab in WooCommerce

March 6, 2020 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. Use the following snippet to add […]

Read More →

Change number of products displayed per page in WooCommerce

February 28, 2020 in Code Snippets

Use the following code to change the number of WooCommerce products displayed per page. This requires you to have your shop page display, which can be found in customizer view under WooCommerce > Product catalog set to “Show products”. Add this code to your child theme’s functions.php file or via a plugin that allows custom […]

Read More →

Creating a new simple product in WooCommerce

February 1, 2020 in Code Snippets

$product = new WC_Product_Simple(); $product->set_name( 'My Product' ); $product->set_slug( 'myproduct' ); $product->set_description( 'A new simple product' ); $product->set_regular_price( '9.50' ); $product->save(); $product_id = $product->get_id();

Read More →

Change number of related products output in WooCommerce

January 11, 2020 in Code Snippets

Please note that it may not work for all themes because of the way they are coded. Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file […]

Read More →

Set a custom add to cart URL to redirect to in WooCommerce

December 23, 2019 in Code Snippets

Read More →

Change number of upsells output in WooCommerce

December 19, 2019 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Change number of upsells […]

Read More →

Hide trailing zeros on prices in WooCommerce

November 5, 2019 in Code Snippets

The option to show trailing zeros on your prices has been removed in favor of a filter, as of WooCommerce 2.2x. Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your […]

Read More →

Add a standard currency value surcharge to all transactions in WooCommerce

November 3, 2019 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Add a standard $ […]

Read More →

Change email subject lines in WooCommerce

July 29, 2019 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /* * goes in theme functions.php […]

Read More →

Notify Admin When New Account Is Created in WooCommerce

July 24, 2019 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Notify admin when a […]

Read More →

Check if WooCommerce is active

June 21, 2019 in Code Snippets

Most WooCommerce plugins do not need to run unless WooCommerce is already active. You can wrap your plugin in a check to see if WooCommerce is installed: // Test to see if WooCommerce is active (including network activated). $plugin_path = trailingslashit( WP_PLUGIN_DIR ) . 'woocommerce/woocommerce.php'; if ( in_array( $plugin_path, wp_get_active_and_valid_plugins() ) || in_array( $plugin_path, wp_get_active_network_plugins() […]

Read More →

Display Different Content for Different Categories in WooCommerce

June 20, 2019 in Code Snippets

Display different content for different categories. if ( is_product_category() ) { if ( is_product_category( 'shirts' ) ) { echo 'Hi! Take a look at our sweet tshirts below.'; } elseif ( is_product_category( 'games' ) ) { echo 'Hi! Hungry for some gaming?'; } else { echo 'Hi! Check our our products below.'; } }

Read More →

The Additional Information tab in WooCommerce

June 16, 2019 in Code Snippets

Please note that the “Additional Information” tab will only show if the product has weight, dimensions or attributes (with “Visible on the product page” checked). If you try to apply a change to that tab and if the product does not have weight, dimensions or attribute, you will get an error message. In that case, […]

Read More →

Enable the product gallery in WooCommerce theme

June 12, 2019 in Code Snippets

To enable the product gallery in your theme, you can declare support like this. add_theme_support( 'wc-product-gallery-zoom' ); add_theme_support( 'wc-product-gallery-lightbox' ); add_theme_support( 'wc-product-gallery-slider' );

Read More →

Change a currency symbol in WooCommerce

June 1, 2019 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Change a currency symbol […]

Read More →

Automatically Complete Orders in WooCommerce

April 8, 2019 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Auto Complete all WooCommerce […]

Read More →

wc_price – WooCommerce Core Function

March 28, 2019 in Code Snippets

The following useful function is found in the includes/wc-core-functions.php and can be used by themes and plugins. Formats a passed price with the correct number of decimals and currency symbol. wc_price( $price, $args = array() )

Read More →

Make WooCommerce price widget draggable on touch devices

March 2, 2019 in Code Snippets

Download this script and save it to the JS folder in your theme directory. Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will […]

Read More →

Add/Modify States in WooCommerce

February 13, 2019 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. Don’t forget to add your own […]

Read More →

Add a message above the login / register form in WooCommerce

January 18, 2019 in Code Snippets

Please note that for this code to work you’ll need to have the “Account creation” settings for customers checked, in “Accounts & Privacy”. Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly […]

Read More →

Changing image sizes via hooks in WooCommerce

November 24, 2018 in Code Snippets

If you need more control over thumbnail sizes here is a hook available to you. add_filter( 'woocommerce_get_image_size_gallery_thumbnail', function( $size ) { return array( 'width' => 150, 'height' => 150, 'crop' => 0, ); } );

Read More →

Add a custom field (in an order) to the emails in WooCommerce

October 26, 2018 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Add a custom field […]

Read More →

Prevent Data Leaks in WooCommerce

October 17, 2018 in Code Snippets

Try to prevent direct access data leaks. Add this line of code after the opening PHP tag in each PHP file. if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly }

Read More →

Display product weight on archive pages in WooCommerce

October 10, 2018 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. WooCommerce 3.0+ /** * Show product […]

Read More →

Display product dimensions on archive pages in WooCommerce

October 4, 2018 in Code Snippets

Display WooCommerce product dimensions on archive pages, below the title of the product. Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be […]

Read More →

Optional WooCommerce Theme Settings

August 3, 2018 in Code Snippets

These are optional theme settings that you can set when declaring WooCommerce support. function mytheme_add_woocommerce_support() { add_theme_support( 'woocommerce', array( 'thumbnail_image_width' => 150, 'single_image_width' => 300, 'product_grid' => array( 'default_rows' => 3, 'min_rows' => 2, 'max_rows' => 8, 'default_columns' => 4, 'min_columns' => 2, 'max_columns' => 5, ), ) ); } add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );

Read More →

Display My Account link in a template file in WooCommerce

July 12, 2018 in Code Snippets

Displays a link to the user account section. If the user is not logged in the link will display ‘Login / Register’ and take the use to the login / signup page. If the user is logged in the link will display ‘My account’ and take them directly to their account. <?php if ( is_user_logged_in() […]

Read More →

Hook in your functions to display the wrappers in your WooCommerce theme

June 27, 2018 in Code Snippets

Hook in your own functions to display the wrappers your theme requires. Make sure that the markup matches that of your theme. If you’re unsure of which classes or IDs to use, take a look at your theme’s page.php for guidance. add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10); add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10); function my_theme_wrapper_start() { echo '<section id="main">'; } function […]

Read More →

Hide other shipping methods when “Free Shipping” is available in WooCommerce

April 30, 2018 in Code Snippets

Hides everything but free_shipping if it’s available and is compatible with Shipping Zones. Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be […]

Read More →

Adjust the quantity input values in WooCommerce

March 1, 2018 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. Set the starting value, maximum value, […]

Read More →

wc_get_page_id – WooCommerce Core Function

February 19, 2018 in Code Snippets

The following useful function is found in the includes/wc-core-functions.php and can be used by themes and plugins. Gets a WooCommerce page ID by name, e.g. thankyou wc_get_page_id( $page )

Read More →

Custom tracking code for the thank-you page in WooCommerce

January 8, 2018 in Code Snippets

This snippet is for adding tracking for a separate piece of analytic software you may have installed. The order object contains all the order data you should need, including line items. Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky […]

Read More →

Display Category Image on Category Archive in WooCommerce

January 6, 2018 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Display category image on […]

Read More →

Unhook/remove WooCommerce Emails

January 2, 2018 in Code Snippets

This code allows you to unhook and remove the default WooCommerce emails. Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten […]

Read More →

Change add to cart button text in WooCommerce

December 31, 2017 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. // Change add to cart text […]

Read More →

Disable the product gallery in WooCommerce theme

December 11, 2017 in Code Snippets

You can disable product gallery features with the code below. remove_theme_support( 'wc-product-gallery-zoom' ); remove_theme_support( 'wc-product-gallery-lightbox' ); remove_theme_support( 'wc-product-gallery-slider' );

Read More →

Allow HTML in term (category, tag) descriptions in WooCommerce

December 2, 2017 in Code Snippets

By default, WordPress strips HTML from category descriptions. This code will prevent that from happening. The first part prevents HTML from being stripped from term descriptions. The second part prevents HTML being stripped out when using the term description function. Add this code to your child theme’s functions.php file or via a plugin that allows […]

Read More →

wc_get_dimension – WooCommerce Core Function

October 16, 2017 in Code Snippets

The following useful function is found in the includes/wc-core-functions.php and can be used by themes and plugins. Takes a measurement (dim) measured in WooCommerce’s dimension unit and converts it to the target unit ($to_unit). wc_get_dimension( 10, 'lbs' )

Read More →

wc_mail – WooCommerce Core Function

October 10, 2017 in Code Snippets

The following useful function is found in the includes/wc-core-functions.php and can be used by themes and plugins. Used to send an email using the WooCommerce email templates. wc_mail( $to, $subject, $message, $headers = "Content-Type: text/htmlrn", $attachments = "" )

Read More →

Check if the billing address contains a house number in WooCommerce

September 29, 2017 in Code Snippets

Currently, when using the Checkout block from the WooCommerce Blocks plugin, there’s no check if the billing or shipping address field contains a house number. The following code snippets allow to check if these fields contain a number. To check if the billing address contains a house number, please use the following code snippet: add_action( […]

Read More →

Add a surcharge based on the delivery country in WooCommerce

September 9, 2017 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Add a 1% surcharge […]

Read More →

Define theme image sizes in WooCommerce

September 7, 2017 in Code Snippets

add_theme_support( 'woocommerce', array( 'thumbnail_image_width' => 200, 'gallery_thumbnail_image_width' => 100, 'single_image_width' => 500, ) );

Read More →

Add UK postal counties to WooCommerce

August 29, 2017 in Code Snippets

This snippet adds UK postal counties to WooCommerce’s list of states. Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely […]

Read More →

Change the placeholder image in WooCommerce

August 20, 2017 in Code Snippets

The placeholder image can now be set at: WooCommerce > Settings > Products as of version 3.5x. WooCommerce 3.4x or earlier Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your […]

Read More →

Add a percentage based surcharge to all transactions in WooCommerce

July 13, 2017 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Add a 1% surcharge […]

Read More →

Using filter hooks in WooCommerce

May 29, 2017 in Code Snippets

Filter hooks are called throughout are code using apply_filter( ‘filter_name’, $variable );. To manipulate the passed variable, you can do something like the following. add_filter( 'filter_name', 'your_function_name' ); function your_function_name( $variable ) { // Your code return $variable; } With filters, you must return a value.

Read More →

Do not allow PO BOX shipping in WooCommerce

May 21, 2017 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Prevent PO box shipping […]

Read More →

Custom sorting options (asc/desc) in WooCommerce

May 16, 2017 in Code Snippets

This example code shows how you can add an order option for ‘random’, but this also works in similar ways for other ways to order your products on the catalog page. Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky […]

Read More →

Show cart contents / total in WooCommerce

May 13, 2017 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. To display the cart contents and […]

Read More →

Allowing customer access to WP Admin and enabling the admin bar in WooCommerce

May 5, 2017 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. By default, WooCommerce blocks non-admin users […]

Read More →

Customize a tab in WooCommerce

April 27, 2017 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. The following snippet will replace the […]

Read More →

Adding Custom Fields To Emails in WooCommerce

April 20, 2017 in Code Snippets

To add a custom field value to WooCommerce emails use the following snippet. /* To use: 1. Add this snippet to your theme's functions.php file 2. Change the meta key names in the snippet 3. Create a custom field in the order post – e.g. key = "Tracking Code" value = abcdefg 4. When next […]

Read More →

Re-ordering Tabs in WooCommerce

February 20, 2017 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. Use the following snippet to change […]

Read More →

Disabling WooCommerce styles

January 22, 2017 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. add_filter( 'woocommerce_enqueue_styles', '__return_false' );

Read More →

Rename a country in WooCommerce

January 15, 2017 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. /** * Rename a country */ […]

Read More →

Renaming Tabs in WooCommerce

January 10, 2017 in Code Snippets

Add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Dessky Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be overwritten completely when you update the theme. Use the following snippet to rename […]

Read More →

How to Create a Section in WooCommerce

January 3, 2017 in Code Snippets

We’ll go over doing this through individual functions, but you should probably create a Class that stores all of your settings methods. The first thing you need to is add the section, which can be done like this by hooking into the woocommerce_get_sections_products filter: /** * Create the section beneath the products tab **/ add_filter( […]

Read More →

WooCommerce – Autocomplete all Orders

December 8, 2015 in Code Snippets

What if you just want to automatically complete all of the orders that come in? The following code snippet will do just that!

Read More →

WooCommerce – “Ship to a Different Address” area always visible

December 7, 2015 in Code Snippets

If you want people to see the shipping fields by default, you want that section ALWAYS visible. Here’s how you do it.

Read More →

WooCommerce – Add an Editable Text at the top of Cart page

December 7, 2015 in Code Snippets

Sometimes client will ask you to promptly add some text at the top of cart page and they will have to change this text often.

Read More →

WooCommerce – Change the link of the “Continue Shopping” button

December 7, 2015 in Code Snippets

Below is a quick snippet on how to change link on the “Continue Shopping” button in cart. Hope you will find it helpful.

Read More →

Remove menu items in wp-admin depending on user role

December 7, 2015 in Code Snippets

You will usually find one or more menu items that you don’t want to show to your guest posters. How do you hide them?

Read More →

WooCommerce – Automatically set order status to completed after payment is received

December 7, 2015 in Code Snippets

Sometimes you’ll need to automatically check the payment status and mark an order as completed.

Read More →

30+ Best Ecommerce WordPress Themes

December 6, 2015 in Collections

30-best-ecommerce-themes-for-wordpress

This is collection of the best Ecommerce WordPress Themes on the market. Themes are specially handpicked and tested by our development team and you can not make any mistake by choosing any of them for your online store.

Read More →

Yolee – Flat Multi-Purpose Responsive WooCommerce Theme

June 27, 2014 in Themes

yolee-692-303

Yolee is a Flat Responsive Multi-Purpose WooCommere Theme with many layout options and unlimited color variations.

Read More →

Remove the Product Count on Categories in WooCommerce

May 5, 2014 in Code Snippets

This snippet will remove the product count functionality site-wide.

Read More →

Automatically Complete Orders in WooCommerce

May 5, 2014 in Code Snippets

Auto Complete all WooCommerce orders.

Read More →

Change the Billing Address Label on the WooCommerce Checkout Page

May 5, 2014 in Code Snippets

woocommerce-shipping-billing-address-label

This code snippet lets you change the main label for either the Billing Address section or Shipping Address section.

Read More →

NanoShop – Multi-Purpose Responsive WooCommerce Theme

January 9, 2014 in Themes

nanoshop-banner-692-303

NanoShop is a Responsive Multi-Purpose WooCommere Theme with many layout options and unlimited color variations.

Read More →

NanoShop Lite – FREE and lightweight WooCommerce theme

December 19, 2013 in Themes

NanoShop Lite

NanoShop Lite is FREE version of the Premium NanoShop Theme and it offers lightweight yet powerful functionality.

Read More →

MiniMart – Modern WooCommerce WordPress Theme

November 5, 2013 in Themes

MiniMart – Modern WooCommerce WordPress Theme

MiniMart is a unique eCommerce theme with flat and metro elements built specifically for WooCommerce.

Read More →

New WooShop 2.0 Theme arrives!

July 8, 2013 in Blog

New WooShop 2.0 Theme arrives!

A new version of our WooCommerce Theme – WooShop – Version 2.0 – has been released. Theme improvements include: WordPress 3.5.2 Ready, WooCommerce 2+ Ready

Read More →

Display number of items in cart together with total – WooCommerce

June 9, 2013 in Blog, Code Snippets

How to display number of items in cart together with total in WooCommerce.

Read More →

Get List of Coupons used by one Customer in all WooCommerce orders

May 3, 2013 in Blog, Code Snippets

The beauty of code snippets is their ability to save you time when developing a site. If you are a WooCommerce developer you may find this snippet usefull for Coupons listing.

Read More →
dehghani.stacie@mailxu.com mccainehilario@mailxu.com