• Hello Jose,

    Thanks for the great plugin.

    I ran into a problem – if I insert another shortcode into the plugin shortcode – it doesn’t show up or has an unexpected result.

    I will describe 2 situations that I encountered.

    1. When using the code to display “last viewed items” ( code below ). I add the shortcode: [recently_viewed_products] and display the content of the shortcode:
    [content_no_cache id=”11344″].

    The unexpected result is that the column output breaks. Instead of 6 set outputs 4.

    I tried to display [content_no_cache id=”11344″ request=”remote”] – in this case, the content is not displayed at all.

    2. I decided to use in conjunction with

    Your plugin + Geotargeting Plugin https://ru.ww.wp.xz.cn/plugins/wt-geotargeting/ (displays content as a shortcode) + estimated delivery plugin. https://ww.wp.xz.cn/support/plugin/estimated-delivery-for-woocommerce/ (also shortcode)

    It turns out that in order not to cache part of the content, I placed the “content no cache” plugin shortcode on the product page.

    In the “content no cache” plugin shortcode, I put the content inside:
    [wt_geotargeting city_show=”Milano”]<div>Estimate delivery: [estimate_delivery] </div>[/wt_geotargeting]
    [wt_geotargeting city_show=”Rome”]<div>Estimated delivery: 3 days</div>[/wt_geotargeting]

    The text is displayed completely. But the [estimate_delivery] shortcode content is empty. I tried [content_no_cache id=”11347″ request=”remote”] but it didn’t work.

    The plugin uses ajax – but I disabled this setting, which should have solved this issue.

    Please tell me what I need to do to make everything work perfectly?
    Thanks again for the plugin and for your work!

Viewing 1 replies (of 1 total)
  • Thread Starter N.g

    (@loralora)

    add_action( 'template_redirect', 'tr_recently_viewed_product_cookie', 20 );
     
    function tr_recently_viewed_product_cookie() {
     
    	if ( ! is_product() ) {
    		return;
    	}
    
    	if ( empty( $_COOKIE[ 'woocommerce_recently_viewed_2' ] ) ) {
    		$viewed_products = array();
    	} else {
    		$viewed_products = (array) explode( '|', $_COOKIE[ 'woocommerce_recently_viewed_2' ] );
    	}
    
    	if ( ! in_array( get_the_ID(), $viewed_products ) ) {
    		$viewed_products[] = get_the_ID();
    	}
    
    	if ( sizeof( $viewed_products ) > 15 ) {
    		array_shift( $viewed_products ); 
    	}
    
    	wc_setcookie( 'woocommerce_recently_viewed_2', join( '|', $viewed_products ) );
     
    }
    add_shortcode( 'recently_viewed_products', 'tr_recently_viewed_products' );
     
    function tr_recently_viewed_products() {
     
    	if( empty( $_COOKIE[ 'woocommerce_recently_viewed_2' ] ) ) {
    		$viewed_products = array();
    	} else {
    		$viewed_products = (array) explode( '|', $_COOKIE[ 'woocommerce_recently_viewed_2' ] );
    	}
     
    	if ( empty( $viewed_products ) ) {
    		return;
    	}
     
    	$viewed_products = array_reverse( array_map( 'absint', $viewed_products ) );
     
    	$title = '<h3></h3>';
     
    	$product_ids = join( ",", $viewed_products );
     
    	return $title . do_shortcode( "[products ids='$product_ids' limit='6' columns='6']" );
     
    }

    [recently_viewed_products]

Viewing 1 replies (of 1 total)

The topic ‘Shortcode content is empty, another shortcode is displ. with unexpected result’ is closed to new replies.