LOOKING FOR A COMPREHENSIVE GUIDE TO USING WOOCOMMERCE SHORTCODES?

LOOK NO FURTHER!

 

First things first are the pages WooCommerce creates when first installed and activated, if everything went well then you won’t have a need for these next shortcodes. But, as you’re using WordPress it’s highly likely a few things need some manual intervention. WooCommerce should create 11 preconfigured pages for your cart, checkout, etc. However, if it doesn’t, you accidentally deleted one or you’re just naturally curious here are the 11 shortcodes for creating dedicated WooCommerce pages: NB: When copying shortcodes, be sure to paste without formatting, so Cmd+Shift+V on a Mac or Ctrl+Shift+V on Windows.

  • [[woocommerce_cart]] – This will show the customers’ cart.
  • [[woocommerce_checkout]] – This will show the checkout page.
  • [[[woocommerce_pay]]] – This will show the Checkout -> Pay Page, used for some gateways.
  • [[[woocommerce_thankyou]]] – This shows the Order Received page, put your conversion tracking codes here!
  • [[woocommerce_order_tracking]] – This shows the Order Tracking page.
  • [[woocommerce_my_account]] – This will display the My Account Page.
  • [[[woocommerce_edit_address]]] – This page allows customers to edit their billing and shipping addresses.
  • [[[woocommerce_view_order]]] – This page allows customers to view individual order details.
  • [[[woocommerce_change_password]]] – Allows the customer to change their password.
  • [[[woocommerce_lost_password]]] – This page will display a lost password form.
  • [[woocommerce_logout]] – This will display a logout link.

It should be noted that some of these shortcodes can be combined, for example you could set up a settings page with [[[woocommerce_edit_address]]],  [[[woocommerce_change_password]]], [[woocommerce_logout]] for convenience.

When you install WooCommerce you’ll also find a new icon in your WYSIWYG editor (the post/pages editor), which will look very much like this: woocommerce-shortcode-kitchen-sink If you click on it you’ll find a drop down list of the various shortcodes specific to WooCommerce:

WooCommerce Shortcode Dropdown

PRODUCT PRICE/CART BUTTON

When you click this option you’ll see the following shortcode added to your editor: [[add_to_cart id=”” sku=””]]. This can be used to show the price and add to cart button for a singular product, wither by id or SKU. It also allows a style=”” argument to apply custom CSS. You can find the id of a product by navigating to the products page in your WP admin and hovering over the product in question, you’ll see a greyed out id number like so:

woocommerce-find-id-number

PRODUCT BY SKU/ID

Clicking this option will place this shortcode into your editor: [[product id=”” sku=””]]. This is fairly self explanitory and will display a singular product with specific id or SKU, e.g.

  • [[product id=”97″]]
  • [[product sku=”CLUBM”]]

PRODUCTS BY SKU/ID

Very similar to the previous example, this will output multiple products and insert this shortcode: [[products ids=”” skus=””]]. You can also apply the following arguments; order=” “, columns=” “, orderby=” “. For example this shortcode: [[products ids=”1, 2, 3, 4, 5, 6, 7, 8, 9, 10″ columns=”2″ order=”asc” orderby=”date”]] would output 10 products in 2 columns ordered by date in ascending order. You can also use desc for descending and title for ordering.

PRODUCT CATEGORIES

Product categories will display the product categories loop and output this shortcode: [[product_categories number=””]].  Specifying a number will output that many categories. There are 7 more arguments you can apply to this shortcode:

  • number‘ => ‘null‘, – This determines the number of categories.
  • orderby‘ => ‘name‘, – This determines the order, “name” and “date” are valid options.
  • order‘ => ‘ASC‘, – Determines how product categories are ordered, “ASC” or “DESC“.
  • columns‘ => ‘4′, – The number of columns categories are arranged into.
  • hide_empty‘ => ‘1‘, – Set to 1 to hide categories with no products or to show them.
  • parent‘ => ”, – Set to 0 to only display top-level categories.
  • ids‘ => ” – ids can be set to only output those specified.

 

PRODUCT CATEGORIES BY SLUG

This will output the shortcode: [[product_category category=”” per_page=”12″ columns=”4″ orderby=”date” order=”desc”]]. Similar to product categories but this will output all products within the specified category and can be arranged with the per_page=”” and columns=”” parameters. The category slug can be found by navigating to the product menu in your WP admin and clicking on categories where you’ll see a list of all available categories and corresponding slugs.

 

RECENT PRODUCTS

Recent Products will output, strangely enough, recently added products. The shortcode will look like this: [[recent_products per_page=”12″ columns=”4″ orderby=”date” order=”desc”]]. All arguments are output by default and have the same options as previous examples.

 

FEATURED PRODUCTS

Featured products is identical to recent products, except it will output products that have been marked favourite, rather than recently added products. The shortcode is:[[featured_products per_page=”12″ columns=”4″ orderby=”date” order=”desc”]].

SALE PRODUCTS

This and the next few shortcodes are not listed under the Woo icon, we’re not sure why, but there’s not much we can do about it! [[sale_products]] outputs your products currently on sale and can be adjusted with the following arguments:

  • per_page‘ => ’12’,
  • columns‘ => ‘4‘,
  • orderby‘ => ‘title‘,
  • order‘ => ‘asc

BEST SELLING PRODUCTS

To output your best selling products you can use this shortcode: [[best_selling_products]], this shortcode only accepts the following arguments though:

  • per_page‘ => ‘12‘,
  • columns‘ => ‘4

TOP RATED PRODUCTS

If you use the ratings and reviews feature built into WooCommerce then this shortcode can be quite useful for displaying your best products; [[top_rated_products]]. It can be altered with the following arguments:

  • per_page‘ => ‘12‘,
  • columns‘ => ‘4‘,
  • orderby‘ => ‘title‘,
  • order‘ => ‘asc

RELATED PRODUCTS

Whilst most themes will include a related products area in single product listings, you may want to make use of this shortcode for more custom uses. [[related_products]] will output related products. You can use the following arguments:

  • per_page‘ => ‘12‘,
  • columns‘ => ‘4‘,
  • orderby‘ => ‘title

I commenti sono chiusi.