Usage

Shortcodes

asa

shortcode_asa_1

To embed products from Amazon into your post with AmazonSimpleAdmin, easily use shortcodes like this:

where ASIN is the Amazon ASIN number you can find on each product’s site, like:

Furthermmore you can declare an individual template file within the first asa shortcode, like:

(notice the space after asa!)

You can create multiple template files and put them into the “tpl” folder in the AmazonSimpleAdmin plugin directory. Template files are simple HTML files with placeholders. See the Step by Step Guide for more info. Template files must have the extension “.htm”. Use the filename without “.htm” for declaration within the asa shortcode. If you do not declare a template file, AmazonSimpleAdmin uses the default template (tpl/default.htm).

asa_collection

For embedding a whole collection of Amazon products into your post, use the collection shortcodes:

where “my_collection” between the tags stands for the collection label you have created in the collections section.

Like with the simple ASIN shortcodes before, you can also use templates for collections. Declare your template file in the asa_collection tag, like this:

Collections options:

KeyValue
items(integer) How many collection items you want to display
typeThe type of display:

  • “latest”: Only the latest collection item
  • “random”: Randomly ordered items
  • “all”: All collection items

You can combine these options, like:

This example would only display one random collection item.

PHP functions

AmazonSimpleAdmin features the following functions, which can be used in your sidebar file or everywhere else in PHP code.

asa_item

Displays one item defined by $asin

  • asin
    Stands for the amazon ASIN
  • tpl
    Defines your template file. Default is “sidebar_item”

asa_get_item

Returns the rendered template.

  • asin
    Stands for the amazon ASIN
  • tpl
    Defines your template file. Default is “sidebar_item”

asa_collection

Displays one or more collection items.

  • label
    The collection label
  • type
    Available options: all, latest
    “all” lists all collection items sorted by time of adding whereas “latest” only displays the latest added item. Default is “all”
  • tpl
    Defines your template file. Default is “collection_sidebar_default”

asa_get_collection

Returns the rendered collection.

  • label
    The collection label
  • type
    Available options: all, latest
    “all” lists all collection items sorted by time of adding whereas “latest” only displays the latest added item. Default is “all”
  • tpl
    Defines your template file. Default is “collection_sidebar_default”

Custom Fields

You can easily combine ASA with WordPress’ custom field feature.

Custom page template

This is a simple example to give you an idea of the concept. It uses a custom page template. It is very easy to create a custom page for your theme. Refer to the WordPress codex if you are new to page templates: http://codex.wordpress.org/Page_Templates

For this example I call my custom page “ASA Custom Field”:

Then I create a new page and select my new template:

custom_field_page_template

Below the page editor I enter a new custom field with name “ASIN”. The value is the ASIN of the product I want to include on this page.

custom_field

If you do not have this “Custom Fields” section on your page, you have to activate it in your screen option on top of the page:

custom_field_screen_options

Finally I have to include a PHP code snippet in my custom page template where I want to display the Amazon product:

The important part here is ‘ASIN’. This has to match the custom field’s name. If you want to use a custom ASA template, easily change ‘default’ to the filename of your template.

That’s it. Now the product will be shown where you included the PHP code. You can extend this example by adding more custom fields, custom ASA templates, PHP code conditions etc. Let your creativity run wild! 🙂

For a better flexibility when working with custom fields I recommend the plugin “Advanced Custom Fields“.

Share this Post

Comments 5

  1. Pingback: New update adds Amazon India and backend translation - AmazonSimpleAdmin

  2. Haroun Kola

    Thanks, I’ve just installed your plugin and it’s subtle effect is in the post I’ve linked to this comment. I’m going to test it out some more and hopefully get some affiliate sales going with some awesome content.

  3. Alisa Shtromberg

    Great plugin! I tried many different ones before stumbling onto yours and it has been by far the most customizable and simple to implement. And great job on the documentation.

    Just a quick question: I am utilizing the collections and for the items integer value, if I were to use 0 for the value would it just display all of them? Or should I just leave out the items code and it would display all of them?

    Also is there a way to display them alphabetically?

    Thanks!

  4. Nick

    Hi,

    I am trying to use this php method to display the custom field value on my single product page.

    I have added a custom field ‘asin’ for a product and gave the asin number to the field. I used the above php code but nothing is displayed. I don’t get any error either. Just using the ASIN in the product description display the data from Amazon without any issues.

    Here’s my code,

    echo asa_item(get_post_meta($post->ID, 'asin', true), 'default_one');

    “default_one” is my template name. What could be wrong?

    1. Timo

      Hi Nick,
      to be sure that the custom field works as expected, check if the output of get_post_meta($post->ID, ‘asin’, true) returns the ASIN you have defined.

      Then please use the function asa_get_item to echo the result as asa_item will echo the result directly.

Leave a Reply

Your email address will not be published. Required fields are marked *