• Contextual ads working but no longer working on any of my sites. When I try to create a new contextual ad it says I need api key which I cannot get yet. This was not the case before, it used to work without it before. Help.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author miunosoft

    (@miunosoft)

    Hi,

    Yes, since the end of SiteStripe, the plugin now requires PA-API keys except for Category units. So resort to Category units until a new method is established.

    For what I see SiteStripe has removed images but not the text link.

    Why it is not possible to use the contextual ads with the text template?

    Also all links using the shortcode are not working either.
    [amazon_auto_links asin=”B0BLP1HYDS”]

    Same here, I have updated the settings default to take the text template that has no image but nothing is returned.

    Plugin Author miunosoft

    (@miunosoft)

    @guaranis

    Why it is not possible to use the contextual ads with the text template?

    When the asin argument is passed the plugin performs an API query with an Item Look-up unit. And if there is a problem during it, no products will be shown.

    But you have a point. This process is indeed not needed if you only want to display a text link. This kind of situation hasn’t been assumed. Let me think how it could be done.

    Did you find a solution to have the contextual, search, url, shortcode to work again with the text template?

    Plugin Author miunosoft

    (@miunosoft)

    Can you try adding the following code to the functions.php file?

    add_filter( 'aal_filter_products', function( $products, $urls, $unitOutput ) {
    
        $_asins = array_unique( array_merge(
            ( array ) $unitOutput->oUnitOption->get( 'asin' ),
            ( array ) $unitOutput->oUnitOption->get( 'ItemIds' )
        ) );
        if ( empty( $_asins ) ) {
            return $products;
        }
        $_locale  = new AmazonAutoLinks_Locale( $unitOutput->oUnitOption->get( 'country' ) );
        $products = $unitOutput->getAsArray( $products );
        foreach( $_asins as $_asin ) {
            if (
                isset( $products[ $_asin ], $products[ $_asin ][ 'formatted_item' ] )
                 && $products[ $_asin ][ 'formatted_item' ] )
            {
                continue;
            }
            $products[ $_asin ] = isset( $products[ $_asin ] ) && is_array( $products[ $_asin ] )
                ? $products[ $_asin ]
                : array();
            $_urlProduct = $_locale->getMarketPlaceURL( '/dp/' . $_asin );
            $products[ $_asin ][ 'formatted_item' ] = "<p>"
                    . "<a href='" . esc_url( $_urlProduct ) . "' rel='nofollow noopener' target='_blank'>" . $_urlProduct . "</a>"
                . "</p>";
        }
    
        $unitOutput->aErrors = array(); // clear unit errors
        return $products;
    
    }, 10, 3 );

    The function return only the url, not the title and not working with the search: [amazon_auto_links search=”WordPress”]

    For now I have disabled the plugin and use the shorcode already in my posts with my own function that does the same, display the link.

    function amazon_auto_links($atts) {
    	if (isset($atts['asin'])) {
    		$asin = $atts['asin'];
    		$div = '';
    		$tag = 'bookmag03-20';
    		if (strstr($asin, ',')) {
    			$asins = explode(',', $asin);
    			foreach ($asins as $asin) {
    				$div .= '<div class="amz-container"><a  target="_blank" rel="nofollow noopener">Check Price On Amazon</a></div>';
    			}
    		} else {
    			$div = '<div class="amz-container"><a  target="_blank" rel="nofollow noopener">Check Price On Amazon</a></div>';
    		}
    		return $div;
    	}
    }
    add_shortcode('amazon_auto_links', 'amazon_auto_links');

    Plugin Author miunosoft

    (@miunosoft)

    The function return only the url, not the title

    That’s what I understood as what was asked.

    and not working with the search: [amazon_auto_links search=”WordPress”]

    The code I posted handles cases with the asin argument. When the search argument is provided, it should bypass the conversion since the ASINs of the products cannot be determined without PA-API keys, and consequently, their titles.

    Anyway, you seem to have found a way, then that’s good.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Contextual Ads no longer working’ is closed to new replies.