Shortcodes

Last updated on Thursday, April 19th, 2012

eShop utilises shortcodes to allow you to list your products in different ways. The shortcodes should be added to the content area of each Post or Page in your shop. If you adding shortcodes to a template file, you will need to use:

<?php echo do_shortcode ('[eshop_shortcode_name attribute1="value1" attribute2="value2"]');?>

Please note that you can only use the attribute tags that are listed for each shortcode. Adding in your own attributes simply will not work.

Product Listings

Shortcodes Attributes: Defaults shown(where applicable)
class panels form show records sortby order list id imgsize excludes links price outofstock
[eshop_list_subpages] eshopsubpages no no 100 10 post_title ASC Not available no 100 Not available yes no yes
[eshop_list_cat_tags] eshopcats no no 100 10 post_title ASC Not available Not available 100 Not available yes no yes
[eshop_list_featured] eshopfeatured no no Not available Not available post_title ASC Not available Not available 100 Not available yes no Not available
[eshop_list_new] eshopsubpages no no 100 10 Not available Not available Not available Not available 100 Not available yes no no
[eshop_random_products] eshoprandomlist no no 6 6 Not available Not available yes Not available 100 0 yes no no
[eshop_show_product] eshopshowproduct no no Not available Not available Not available Not available Not available 0 100 Not available yes no Not available
[eshop_best_sellers] eshopbestsellers no no 100 10 Not available Not available Not available Not available 100 Not available yes no yes
[eshop_list_alpha] eshopalpha no no Not available 25 Not available Not available Not available Not available 100 Not available yes no no
[eshop_sale] eshopfeatured no no Not available Not available post_title ASC Not available Not available 100 Not available yes no Not available

eshop_list_subpages

Display a list of pages with products. Ideal for use on a Department page. From eShop version 6.0.1 onwards, you can hide department pages by setting depts=”no”

eshop_list_cat_tags

Display a list of products using tags or categories. Attributes:

  • type: Available values are:
    • cat: the category id
    • category_name: the category slug
    • tag: the tag name
    • tag_id: the tag id
  • find: Used to define the WordPress category or tag that you want to display. Multiple category ids, tag ids or tag names can be used (separated by commas) but only a single category slug can be used.

Example: [eshop_list_cat_tags type="category_name" find="belt"]

eshop_list_featured

Display products marked as Featured. Suggested use for this is on the main Online Shop page.

eshop_sale

Display products marked as On Sale.

eshop_list_new

Display latest products. Suggested use for this is on a separate Latest Products page.

eshop_random_products

Display a random selection of products. This could be used on the main shop page.

eshop_show_product

Display a specific product or group of products.

eshop_best_sellers

Display the best selling products.

eshop_list_alpha

Display products alphabetically split by alphabet and 0-9. A selection list of A to Z plus 0-9 is included.

Examples

  • [eshop_list_subpages class="myclass"] changes the default class to ‘myclass’
  • [eshop_show_product id="9" class="hilite" panels="yes" form="yes"] shows product ’9′ only. Changes the default class to ‘hilite’, shows the product as a panel and the add to cart form is shown.

Attributes

Please note that you cannot add your own, ad-hoc, attributes to eShop’s shortcodes. You must choose from the options available for that shortcode and you should only add the attributes when you want to change the defaults.

  • class: class="myclass" to change the default class.
  • panels: panels="yes" to show ‘panels’
  • form: form=”yes” to add the shortened add to cart form. By default the qty field is hidden when using panels, but you can re-add it by using form=”yesqty” instead.
  • show: show="10" limits the display to 10 products.
  • records: records="5" limits the number of products shown ‘per page’ to 5.
  • sortby: sortby=”post_title” displays pages in alphabetical order. Possible values: post_date, post_title or menu_order
  • order: order="ASC" display results in ascending, or descending order. Possible values: ASC or DESC
  • list example: list="no" limits the display to 1 random product.
  • id: id="25" or id="25,29,52" shows specific products only. For subpages, only one id can be used.
  • imgsize: imgsize="50" would resize the image to 50% of its original width and height.
  • excludes: excludes="5,14" allows you to exclude items from the list.
  • links: links="no" stops all the links from being generated, useful when combined with form.
  • price: Available values are:
    • price="yes" displays the original price of a product.
    • price="sale" displays the sale price of a product.
    • price="both" displays both the original & sale price of a product.
  • outofstock: outofstock="yes" whether or not to include products not currently in stock. (available from version 6.0.0 onwards)

sortby and order replace the following settings from earlier versions:

  • Featured and department product sort order
  • Random products to display
  • Department Products to display

General Shortcodes

eshop_show_discounts

Display a table of discounts and a paragraph for the free shipping discount.

eshop_show_shipping

Automatically added to the Shipping Rates page and can be amended via the attribute shipclass. Example shipclass="A,B,F" would only display shipping classes A, B and F (dependant on the shipping rate calculation used).

eshop_tax_rates

List the tax bands as created on the tax page. use the attribute zonechecker to add on the forms for checking zones.

eshop_show_payments

Display a list of payment methods available with their associated icons/graphics.

eshop_empty_cart

Custom “empty cart” message. Will only be displayed on the cart page if the cart is empty. Format: [eshop_empty_cart]your_message_goes_here[/eshop_empty_cart]

eshop_cart_items

Display the number of items in the cart via theme templates using the do_shortcode function. Attributes:

  • before and after: Insert text before and after the cart size.
  • hide: hide="yes" will stop the shortcode from displaying anything if the cart is empty.
  • showwhat: Display the number of items, qty total or both

eshop_addtocart

Display the add to cart form after the content of any WordPress Post or Page.
Hide the form from non members using hide="yes"
Specify which product to display using the product’s Post or Page id: [eshop_addtocart id="123"]

eshop_welcome

Display a welcome message. You can use the following attributes:

  • before – which could be used to add mark up
  • returning – perhaps use a phrase like welcome back,
  • guest – the phrase you would like to use for a guest
  • after – again could be used to close the markup.

Usage in templates:

<?php
echo do_shortcode("[eshop_welcome before='<span>' returning='Welcome back' guest='Hello Guest' after='</span>']");
?>

eshop_details

Display product details normally used for the add to cart form. Attributes:

  • show: Comma delimited list of details to display. The list determines the order in which these are displayed. Acceptable values (default order): sku, description, options, optionset, shipping
  • options_hide: Comma delimited list of details to hide from the options and options sets. Acceptable values: option, price, download, weight,stockqty
  • class: Changes the default CSS class

WordPress Theme Development

Top