Home Forums WoodMart support forum Woocommerce Rest API

Woocommerce Rest API

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #196305

    Matys
    Participant

    HI,

    so I’ve exported products to external service, but it took the product descriptions with WPbakery shortcodes. I’ve found out how to change the Rest Api to replace the WPbakery shortcodes with div classess(belowe). Which works fine on my local environment but uploading it to server doesn’t do any changes. Is there something to update in the theme ?

    //Remove WPBakery tags from API
    add_action( 'rest_api_init', function ()
    {
    	register_rest_field(
    		'product',
    		'description',
    		array(
    			'get_callback'    => 'htr_do_shortcodes',
    			'update_callback' => null,
    			'schema'          => null,
    		)
    	);
    });
    function htr_do_shortcodes( $object, $field_name, $request )
    {
    	WPBMap::addAllMappedShortcodes();
    	global $post;
    	$post = get_post ($object['id']);
    	$output['rendered'] = apply_filters( 'the_content', $post->post_content );
    	return $output;
    }
    Attachments:
    You must be logged in to view attached files.
    #196324

    Matys
    Participant

    Ok, nvm I’ve managed to make it work.

    Anyways you could think about adding that to the theme, becouse most of 3rd praties just takes all content from description etc.

    #196384

    Hello,

    The product page is Woocommerce functionality and the theme does not influence that. You can share your final valid code here for other users who would need to do the same.

    Best Regards

    #196487

    Matys
    Participant

    Hi,

    this is the valid code, the issue was within something else. So if anyone puts that into functions.php it should work fine.

    #196524

    Thank you very much!

    Best Regards

Viewing 5 posts - 1 through 5 (of 5 total)