Affiliate Super Assistent Shortcodes

Below, you’ll find a detailed guide on how to add the Affiliate Super Assistent Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Affiliate Super Assistent Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Affiliate Super Assistent Plugin and the shortcodes it provides:

Plugin Icon
Affiliate Super Assistent

"Affiliate Super Assistant is a WordPress plugin designed to streamline your Amazon affiliate marketing. With its user-friendly interface, it makes managing your affiliate links simpler and more efficient."

★★★★✩ (34) Active Installs: 3000+ Tested with: 6.3.2 PHP Version: 7.2
Included Shortcodes:
  • [asa]
  • [asa_collection]

Affiliate Super Assistent [asa] Shortcode

The AmazonSimpleAdmin plugin shortcode ‘asa’ is used to handle Amazon product display on a WordPress site. It accepts product ASIN as content and optional parameters like ‘comment’ and ‘class’. The shortcode fetches the product details from Amazon, using the provided ASIN, and displays it on the website with the specified template. The ‘comment’ and ‘class’ options allow you to add custom comments and CSS classes to the product display.

Shortcode: [asa]

Parameters

Here is a list of all possible asa shortcode parameters and attributes:

  • options – Array of additional parameters to customize the shortcode
  • content – Contains the ASIN (Amazon Standard Identification Number)
  • code – The name of the shortcode being processed
  • comment – Optional text to be displayed with the shortcode
  • class – Optional CSS class for styling the shortcode output
  • tplName – Optional template name for customizing the shortcode output

Examples and Usage

Basic example – A simple shortcode to display an Amazon product by referencing its ASIN (Amazon Standard Identification Number).

[asa]B08L8KC1J7[/asa]

Advanced examples

Using the shortcode to display an Amazon product with a custom comment and class. The comment and class are optional parameters/attributes (atts) that can be used to customize the output.

[asa comment="This is a great product" class="my-custom-class"]B08L8KC1J7[/asa]

Using the shortcode to display an Amazon product using a custom template. The template name should be specified in the ‘tpl’ attribute. If the specified template is not found, the default template will be used.

[asa tpl="my_custom_template"]B08L8KC1J7[/asa]

Note: The ‘tpl’ attribute is used to specify the name of the template to be used for rendering the product. The template should be located in the ‘templates’ directory of the AmazonSimpleAdmin plugin.

PHP Function Code

In case you have difficulties debugging what causing issues with [asa] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'asa', array($this, 'handleShortcodeAsa'));

Shortcode PHP function:

function handleShortcodeAsa($options, $content = '', $code = '')
    {
        $output = '';
        $asin = $content;

        if (!empty($asin)) {

            $options = array_map('asa_sanitize_shortcode_option_value', asa_var_to_array($options));

            if (isset($options['comment'])) {
                $options['comment'] = html_entity_decode($options['comment']);
            }
            if (isset($options['class'])) {
                $options['class'] = html_entity_decode($options['class']);
            }

            $tplName = asa_get_tpl_name_from_options($options);

            $tplSrc = $this->getTpl($tplName, true);

            $output = $this->parseTpl($asin, $tplSrc, $options, $tplName);
        }

        return $output;
    }

Code file location:

amazonsimpleadmin/amazonsimpleadmin/AsaCore.php

Affiliate Super Assistent [asa_collection] Shortcode

The AmazonSimpleAdmin shortcode, ‘asa_collection’, is designed to manage and display collections of Amazon products on your WordPress site. This shortcode retrieves a specific collection using its ID, then displays the items in the collection. It offers customization options like ‘type’ to display items randomly or the latest ones and ‘limit’ to control the number of items shown. It also applies a template for the display style, which can be customized.

Shortcode: [asa_collection]

Parameters

Here is a list of all possible asa_collection shortcode parameters and attributes:

  • type – Determines the order of the collection items. ‘random’ for random order, ‘latest’ for the newest item.
  • limit – The maximum number of collection items to display.
  • items – An alternative way to set the maximum number of collection items to display.

Examples and Usage

Basic example – Displaying an Amazon Simple Admin collection based on its ID.

[asa_collection]1[/asa_collection]

Advanced examples

Displaying an Amazon Simple Admin collection in a random order.

[asa_collection type="random"]1[/asa_collection]

Limiting the number of items displayed from an Amazon Simple Admin collection.

[asa_collection limit="5"]1[/asa_collection]

Displaying the latest item from an Amazon Simple Admin collection.

[asa_collection type="latest"]1[/asa_collection]

Using a specific template for displaying an Amazon Simple Admin collection.

[asa_collection tplName="my_template"]1[/asa_collection]

PHP Function Code

In case you have difficulties debugging what causing issues with [asa_collection] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'asa_collection', array($this, 'handleShortcodeAsaCollection'));

Shortcode PHP function:

function handleShortcodeAsaCollection($options, $content = '', $code = '')
    {
        $output = '';

        require_once(dirname(__FILE__) . '/AsaCollection.php');
        $this->collection = new AsaCollection($this->db);

        $collection_id = $this->collection->getId(trim($content));
        $coll_items = $this->collection->getItems($collection_id);

        if (count($coll_items) == 0) {
            // not items found, return empty output
            return $output;
        }

        $options = array_map('asa_sanitize_shortcode_option_value', asa_var_to_array($options));

        $tplName = asa_get_tpl_name_from_options($options);

        // random
        if (isset($options['type'])) {
            if ($options['type'] == 'random') {
                shuffle($coll_items);
            } elseif ($options['type'] == 'latest') {
                $coll_items = array_slice($coll_items, 0, 1);
            }
        }

        // limit results
        if (isset($options['limit']) && is_numeric($options['limit'])) {
            $limit = (int)$options['limit'];
        } elseif (isset($options['items']) && is_numeric($options['items'])) {
            $limit = (int)$options['items'];
        }

        if (isset($limit) && $limit > 0) {
            $coll_items = array_slice($coll_items, 0, $limit);
        }

        $tplSrc = $this->getTpl($tplName, true, true);
        if (Asa_Util_Buffer::exists($tplName, 'tpl_css')) {
            $output .= $this->getCssStyleTag(Asa_Util_Buffer::get($tplName, 'tpl_css'));
        } elseif (Asa_Util_Buffer::exists($this->getDefaultTplName(), 'tpl_css')) {
            $output .= $this->getCssStyleTag(Asa_Util_Buffer::get($this->getDefaultTplName(), 'tpl_css'));
        }

        $coll_items_counter = 1;
        foreach ($coll_items as $row) {
            $output .= $this->parseTpl($row->collection_item_asin, $tplSrc, $options, $tplName);
            $coll_items_counter++;
            if (isset($coll_items_limit) && $coll_items_counter > $coll_items_limit) {
                break;
            }
        }

        return $output;
    }

Code file location:

amazonsimpleadmin/amazonsimpleadmin/AsaCore.php

Conclusion

Now that you’ve learned how to embed the Affiliate Super Assistent Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

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