WAIT: Dynamic tag is not replacing with real value after AJAX action

Bricks Version: 1.5beta
Browser: Safari
OS: macOS.

I got an issue. I am not sure how to resolve it. I built a layout with dynamic tags and all dynamic tags are not replaced with their real value. It is showing the dynamic tags syntax. Please see the attached image.

Screenshot 2022-07-28 at 8.31.30 AM

Screenshot 2022-07-28 at 8.31.54 AM

I used the wp_ajax_ and wp_ajax_nopriv_ hook for AJAX.

1 Like

Hello @bricksultimate

On your custom AJAX calls, inside of your callback are you using any of these methods:

\Bricks\Integrations\Dynamic_Data\Providers::render_tag()

\\ or..

\Bricks\Integrations\Dynamic_Data\Providers::render_content()

No. I did not try it. I shall test and inform you.

I have another question. How to display the child elements of a nestable element with element ID. I retried this code:

add_action( 'bricks_body', function() {
		$settings = \Bricks\Helpers::get_element_data( get_the_ID(), 'jtkhpd' );
		$element_instance = new \MyElements\TestElement( $settings['element'] );
		echo \Bricks\Frontend::render_children( $element_instance );
});

jtkhpd is the parent element ID.

My goal is that I shall fetch the html of child elements only. Can you help me?

not working.

This is my callback code

public function my_custom_ajax_call() {
	check_ajax_referer( 'bu-check-nonce', 'security' );

	$element_id = $_POST['element_id'];
	$post_id = $_POST['post_id'];
	$output = false;

	$output = do_shortcode( '[bricks_template id="'. $element_id .'"]' );

		if( $output ) {
			wp_send_json( $output );
		} else {
			wp_send_json([
				'error' => true
			]);
		}

	wp_die();
}

Where shall I add code?

Hello @bricksultimate,

Ok, now it is clear: you’re trying to render a Bricks template shortcode inside of an AJAX call which is a scenario I need to test on my side.

I’ll get back to you on this.

Hello @bricksultimate

Could you send the $post_id in the $_POST['postId'] i.o. “post_id” ?

I found the issue. Official dynamic tags are working properly. I made custom dynamic tags ({cart_item_price}, {cart_contents_subtotal} etc) and those tags are not working. I am not sure where is the problem. Can I share my custom-made provider file with you? Why you are not just adding the filter in your provider file? So we can easily add the dynamic tags without writing the new providers.php file.

Hello @bricksultimate

Yes, please send us an email to help@bricksbuilder.io.