I am trying to create custom shortcodes to display my WooCommerce cart total in different locations. I have the WooCommerce side of things figured out and if I just use add_action() I am able to include the information I wish to display in select WooCommerce areas, however I am trying to create a custom shortcode so that I can display the shopping cart total in a separate X Theme column. Whenever I try to use add_shortcode() and include the shortcode in a Pro builder page, I am able to save the builder once and then it will load on the front end once. However, if I try to save that page with my custom shortcode again, after attempting to save I always see the notification “Uh oh, failed to save” and I am unable to save and re-publish the page.
I am using a previous Themeco answer as the basis for building my custom shortcode as seen here:
I have tried putting the shortcode creation PHP into my child theme functions.php and in the Code Snippets plugin but both make my page “un-saveable.” Any help would be greatly appreciated.
You can see the code I am using based on that Themeco forum answer and then my shortcode in a text element in the screenshots below. I was unable to capture the error message when saving the page but it is just the generic “Uh oh, failed to save” that happens when any Pro builder page fails to save.
Thank you!