Nested Custom Looper Providers preventing preview from loading?

I have a custom looper that retrieves posts (in this case woocommerce products) where a custom field value existing in the meta query. This bit works fine.

Nested within that looper, I have another custom looper that retrieves the tax price. This also works fine on the front of the site, but in Cornerstone, the preview won’t load if I have the nested custom looper provider active (and pointed at my function).

Maybe I’m being blind, but I cannot see what is wrong with my custom looper function that would cause the preview to stop working:

add_filter( 'cs_looper_custom_dgg_tax_prices', 'dgg_homepage_tax_prices' );
function dgg_homepage_tax_prices( $result ) {
global $product;

$wrap_html_start = '<span style="color: #ffffff;">(<span class="dgg-homepage-exvat-price" style="color: #ffffff;">';
$wrap_html_end = '</span> Inc. VAT)</span><br />';

if ( !empty(wc_get_price_including_tax( $product ))) :
	$tax_price = $wrap_html_start . wc_price( wc_get_price_including_tax( $product ) ) . $wrap_html_end;
endif;
return [
	[ "tax_price" => "$tax_price" ]
];
}

I forgot to add to the above that this problem only occurs in Layouts for a single post. I have the same nested loopers elsewhere on the site but in standard pages without a problem…

Hello @sguilliard,

Thanks for writing in!

Instead of using the Looper, you can easily output the product price which already have included the tax by utilizing the dynamic Price element shortcode:

{{dc:woocommerce:product_price}}

{{dc:woocommerce:product_regular_price}}

You can insert a Raw Content element, put your custom HTML and the Price dynamic content shortcode in it.

<span style="color: #ffffff;">(<span class="dgg-homepage-exvat-price" style="color: #ffffff;">
{{dc:woocommerce:product_price}}
</span> Inc. VAT)</span><br />

Be advised that custom coding is beyond the scope of our support. You may need to contact 3rd party developers to do the troubleshooting for your code. We are unable to provide support for customizations under our Support Policy. If you are unfamiliar with code and resolving potential conflicts, you may select our One service for further assistance.

Best Regards.

Hi @ruenel,

I’ve created a custom looper because the plan is for the function to return more than just the tax inclusive price (this is actually a test tbh), but thanks for the dc shortcodes.

My post wasn’t to ask how to do this, but why something as simple as this would prevent the preview from loading? Is it a conflict? I added my code so you guys could replicate it and look at the cause (which only happens in Layouts)…

Hello @sguilliard,

As we have mentioned before, custom coding is beyond the scope of our support. It is best that you contact a 3rd party developer if you are having difficulty in getting the results that you wanted.

Thank you for your understanding.

Do you even read what people post or just guess at what you think it’s about?!

Where have I asked for any help with custom coding FFS?!

Forget I said anything, just carry on in your own little utopian world where all your code works perfectly… SMH

Hey @sguilliard,

My colleague said it’s outside the scope of theme support because answering your question would involve investigating your custom code which might have coding errors and if that would be the case, we’re basically working on a custom project.

There’s also not enough context in your post, if you like our development team to investigate if there’s something wrong with the builder, please set up a staging site and provide WP Admin and FTP credentials. Just note that the case would be queued for investigation. There’s no schedule so you must keep the staging site online.

Thank you for understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.