Monstroid²
WooCommerce Shortcodes Support
In addition to all the abovementioned features, the template supports all Woocommerce Shortcodes. You simply need to add the content to the shortcode inside the posts and pages to add the elements. In this way, you can save yourself a great deal of time.
Cart
This shortcode is used to display the cart contents and interface for coupon codes and other cart bits and pieces.
[woocommerce_cart]
Checkout
This shortcode should be used on a checkout page only and indicates the checkout process.
[woocommerce_checkout]
Order Tracking Form
This shortcode gives users the status of an order by entering their order details.
[woocommerce_order_tracking]
My Account
Shows the ‘my account’ section where the customer can view the past orders and update their information. You can specify the number or order to show, it’s set by default to 15 (use -1 to display all orders.)
[recent_products per_page="12" columns="4"]
Args:
Recent Products
Lists recent products – useful on the homepage. The ‘per_page’ shortcode determines how many products to show on the page and the columns attribute controls how many columns wide the products should be before wrapping.
[recent_products per_page="12" columns="4"]
Args:
Featured Products
Works the same as the Recent Products but displays the products that have been set as “featured.” In this example, the shortcode says: Show 12 featured products in 4 columns.
[featured_products per_page="12" columns="4"]
Args:
Product
Show a single product by ID or SKU.
[product id="99"]
[product sku="FOO"]
Args:
NOTE: If the product isn’t showing, make sure it isn’t set to Hidden in the Catalog Visibility.
Products
Show multiple products by ID or SKU. Make note of the plural ‘products.’
[products ids="1, 2, 3, 4, 5"]
[products skus="foo, bar, baz" orderby="date" order="desc"]
Args:
NOTE: If the product is not showing, make sure it is not set to Hidden in the Catalog Visibility.
Add to Cart
Show the price and add to cart button of a single product by ID.
[add_to_cart id="99"]
Args:
Add to Cart URL
Echo the URL on the Add to Cart button of a single product by ID.
[add_to_cart_url id="99"]
Args:
Product Page
Show a full single product page by ID or SKU.
[product_page id="99"]
[product_page sku="FOO"]
Product Category
Show multiple products in a category by slug.
Go to: WooCommerce > Products > Categories to find the slug column.
[product_category category="appliances"]
Args:
Product Categories
Display product categories loop
Go to: WooCommerce > Products > Categories to find the slug column.
[product_categories number="12" parent="0"]
Args:
The `number` field is used to display the number of products and the `IDs` field is to tell the shortcode which categories to display.
Set the parent paramater to 0 to only display top level categories. Set IDs to a comma separated list of category IDs to only show those.
Sale Products
List all products on sale.
[sale_products per_page="12"]
Args:
Best-Selling Products
List the best-selling products on sale.
[best_selling_products per_page="12"]
Args:
Top Rated Products
List top-rated products on sale.
[top_rated_products per_page="12"]
Args:
Product Attribute
Lists the products with an attribute shortcode.
[product_attribute attribute='color' filter='black']
Args:
Related Products
List related products.
[related_products per_page="12"]
Args:
The ‘per_page’ Argument
Messed-Up Shortcodes
If you have pasted your shortcodes correctly and the display looks incorrect, make sure you did not embed the shortcode between the tags. This is a common issue. To remove these tags, edit the page, and click the Text tab.
Sorting Products by Custom Meta Fields
In many shortcodes like:
- [recent_products]
- [featured_products]
- [products]
- [product_category]
- [sale_products]
- [top_rated_products]
- [product_attribute]
- [related_products]
you can choose to order products by the following values
- menu_order
- title
- date
- rand
- id
using the “orderby” attribute, for example:
[products skus=”foo, bar, baz” orderby=”date” order=”desc”].
But you can also sort the products by custom meta fields using the code below (in this example we order product by price):
add_filter( 'woocommerce_shortcode_products_query', 'woocommerce_shortcode_products_orderby' ); function woocommerce_shortcode_products_orderby( $args ) { $standard_array = array('menu_order','title','date','rand','id'); if( isset( $args['orderby'] ) && !in_array( $args['orderby'], $standard_array ) ) { $args['meta_key'] = $args['orderby']; $args['orderby'] = 'meta_value_num'; } return $args; }
You need to place this snippet in functions.php in your theme folder and then customize by editing the meta_key.