• Resolved ahbdigital

    (@ahbdigital)


    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

    (@maxidevs)

    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

    (@ahbdigital)

    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

    (@maxidevs)

    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

    (@ahbdigital)

    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

    (@maxidevs)

    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 4 years, 10 months ago by maxidevs.
    Thread Starter ahbdigital

    (@ahbdigital)

    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

    (@maxidevs)

    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 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.