Learn how to set up, customize, and expand the functionality of your WooCommerce products with our library of documentation and tutorials.
  1. Documentation /
  2. Code Snippets /
  3. General Snippets

General Snippets


Documents

  • Change the default cart session length

    When a visitor first adds a product to their cart a session is started that, by default, lasts for 48 hours. When it expires, the items added to the cart are forgotten, meaning the next time that visitor comes by, they’ll find their cart to be empty. The cart session is not related to the […]

  • Configuring Zeus Server Rewrite Rules

    This rewrite.script has been configured for WordPress: RULE_0_START: # get the document root map path into SCRATCH:DOCROOT from / # initialize our variables set SCRATCH:ORIG_URL = %{URL} set SCRATCH:REQUEST_URI = %{URL} # see if there are any queries in our URL match URL into $ with ^(.*)\?(.*)$ if matched then set SCRATCH:REQUEST_URI = $1 set […]

  • Display product attribute archive links

    You will need to 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 Code snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update the theme. Display product […]

  • Display product dimensions on archive pages

    You need to 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 Code snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update the theme. Display WooCommerce product […]

  • Display product weight on archive pages

    To display WooCommerce product weight 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 Code snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be wiped […]

  • Don’t allow PO BOX shipping

    You need to 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 Code snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update the theme. This file contains […]

  • Hide other shipping methods when “Free Shipping” is available

    Overview By default, WooCommerce will show all shipping methods that match the customer and the cart contents. This means Free Shipping will also show along with Flat Rate and other Shipping Methods. The functionality to hide all other methods and only show Free Shipping requires either custom PHP code or a plugin/extension. If you’d like […]

  • Hide trailing zeros on prices

    The option to show trailing zeros on your prices has been removed in favor of a filter, as of WooCommerce 2.2x. If you want to hide trailing zeros on your prices, add the following code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Code snippets plugin. Avoid […]

  • Minimum Order Amount

    Add code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Code snippets plugin. Avoid adding custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update the theme. This file contains bidirectional Unicode text that may […]

  • Notify Admin When New Account Is Created

    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 Code snippets plugin. Avoid adding custom code directly to your parent theme’s functions.php file, as this will be wiped entirely when you update the theme. This file contains bidirectional Unicode text that […]