Title: Shortcode integration
Last modified: April 29, 2020

---

# Shortcode integration

 *  Resolved [ahbdigital](https://wordpress.org/support/users/ahbdigital/)
 * (@ahbdigital)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/shortcode-integration-3/)
 * Hello,
 * I am trying to add the alert with shortcode but the provided [mdwcpt_form product_id
   =] does not seem to work for me.
 * I have setup Modal form trigger link position on product page to “Hide for shortcode
   usage”
 * I have tried with random and specific product id with no success.
 * Any advice for me ?
 * Thank you !

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [maxidevs](https://wordpress.org/support/users/maxidevs/)
 * (@maxidevs)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/shortcode-integration-3/#post-12765306)
 * Hello,
 * I just double tested shortcode on my setup and could not reproduce your issue.
   Could you describe in more detail where exactly you are inserting the shortcode
   and what other plugins are used?
 *  Thread Starter [ahbdigital](https://wordpress.org/support/users/ahbdigital/)
 * (@ahbdigital)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/shortcode-integration-3/#post-12765661)
 * Thank you for your answer. Maybe I am just not understanding correctly the shortcode.
 * the shortcode will be bulk added to all the product pages (via Elementor). What
   do I have to put after product_id= in this case ?
 *  Plugin Author [maxidevs](https://wordpress.org/support/users/maxidevs/)
 * (@maxidevs)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/shortcode-integration-3/#post-12768886)
 * You have to put there id of the product.
 * I tested the shortcode with Elementor, and the only problem is that when you 
   are in edit mode, the result of the shortcode is not previewed automatically,
   but when you save your edits and go to the page, the shortcode works as expected.
   
   This is because of the way plugin loaded is currently not compatible with Elementor
   preview. Perhaps support for this will be added in future releases.
 *  Thread Starter [ahbdigital](https://wordpress.org/support/users/ahbdigital/)
 * (@ahbdigital)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/shortcode-integration-3/#post-12768937)
 * Thank you for testing this.
 * As you might have seen in Elementor you have something to create templates. For
   example we have a template for product pages. Which is used for all our products.
   We usually put shortcodes here because it is impossible to add shortcode manually
   to each product page (we have +10k products).
 * So I cannot add the product id in the shortcode. Is there a shortcode without
   specified product id which will call the id of the product of the actual page?
   
   Usually other plugins with shortcode do that. I can find a way around it by activating
   your plugin before description (or anywhere else you have an option for), then
   hide it and copy the code to somewhere else on the page but this is really not
   a best practice.
 * PS: Most shortcodes don’t have preview in Elementor, this is ok.
 * Thanks again for your help
 *  Plugin Author [maxidevs](https://wordpress.org/support/users/maxidevs/)
 * (@maxidevs)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/shortcode-integration-3/#post-12769238)
 * For now, the shortcode does not work if product_id is not specified … I agree
   that this is very inconvenient, especially in this case.
 * In the next version, support for using the shortcode without the product_id parameter
   will be added. At the moment, as a workaround, you can add the following snippet
   in functions.php of your child theme:
 *     ```
       add_filter( 'shortcode_atts_mdwcpt_form', function( $out ) {
       	if ( empty( $out['product_id'] ) && is_singular( 'product' ) && is_main_query() ) {
       		$out['product_id'] = get_the_id();
       	}
       	return $out;
       });
       ```
   
 * With this code snippet shortcode should work on single product pages without 
   product_id specified. Just [mdwcpt_form] should be enough.
    -  This reply was modified 5 years, 11 months ago by [maxidevs](https://wordpress.org/support/users/maxidevs/).
 *  Thread Starter [ahbdigital](https://wordpress.org/support/users/ahbdigital/)
 * (@ahbdigital)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/shortcode-integration-3/#post-12772368)
 * Hello,
 * Thank you for this, this worked well ! I appreciate your help ?
    Just a little
   thing I am not sure about, when the name on the product page visible is the Submit
   button label instead of the Form title. Is this normal ? I can work on this, 
   just wanted to understand if that was maint to be that way.
 * Something more important, I just noticed that all emails sent by the alert are
   going right to junk mails. Anyway I can work on this ?
    Is the plugin without
   the wp_mail() function ?
 * Thanks
 *  Plugin Author [maxidevs](https://wordpress.org/support/users/maxidevs/)
 * (@maxidevs)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/shortcode-integration-3/#post-12774031)
 * Hello
 * > Just a little thing I am not sure about, when the name on the product page 
   > visible is the Submit button label instead of the Form title. Is this normal?
 * Yes it is intended to be like that.
 * > Something more important, I just noticed that all emails sent by the alert 
   > are going right to junk mails. Anyway I can work on this?
 * Well, this is actually usual thing for shared server installs. WordPress has 
   several plugins for sending email via external SMTP services, and our plugin 
   should probably work with them (but this is untested).
 * > Is the plugin without the wp_mail() function ?
 * The plugin uses the [built-in woocommerce method](https://docs.woocommerce.com/wc-apidocs/source-class-WC_Email.html#593-618)
   to send emails which has some hooks inside… if some other plugin does not overwrite
   $mail_callback variable inside that method with a filter then wp_mail() is used.
   
   That is why the answer depends on what other plugins are used on the site.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Shortcode integration’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/mdwcpt_66b7b9.svg)
 * [MD Price Tracker for WooCommerce](https://wordpress.org/plugins/mdwcpt/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mdwcpt/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mdwcpt/)
 * [Active Topics](https://wordpress.org/support/plugin/mdwcpt/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mdwcpt/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mdwcpt/reviews/)

## Tags

 * [elemenor](https://wordpress.org/support/topic-tag/elemenor/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 7 replies
 * 2 participants
 * Last reply from: [maxidevs](https://wordpress.org/support/users/maxidevs/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/shortcode-integration-3/#post-12774031)
 * Status: resolved