• I set up a staging site and added a new snippet. I have a bunch of snippets that already work. For some reason, this new snippet is not being executed. When I put the same code in my functions file, it works as expected.
    I’m perplexed as to what I’m doing wrong.
    I’m using it with Formidable Forms and checking the form number, as always. And I have it running every where.
    I’m running Formidable Version 5.2.05 and WordPress 5.9.3
    What am I missing?

    Thanks,
    Roger

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter rweiss23

    (@rweiss23)

    Additional note: I tested another snippet and it too does not work on the staging site (but does on the prod site).
    So, what is it about the staging site that is causing these snippets to not fire off?
    I may not be able to sleep tonight!

    RW

    Plugin Author Shea Bunge

    (@bungeshea)

    Hi RW,

    Do you have an example of the sort of code that doesn’t seem to be working?

    Thread Starter rweiss23

    (@rweiss23)

    The code doesn’t seem to matter, as the same code works fine on my production site.
    Its probably something to do with the staging site vs the prod site. It will only execute from the functions.php file on the staging site. And this is true for more than 1 snippet. Thats how I know its not the code.
    Roger

    Plugin Author Shea Bunge

    (@bungeshea)

    Can you try adding a basic snippet like this one, and see if it works?

    add_shortcode( 'snippet_test', function () {
        return 'Snippets are working';
    } );
    Thread Starter rweiss23

    (@rweiss23)

    I added that as a snippet.
    What should I expect to see?

    https://staging2.nepta.com/

    Plugin Author Shea Bunge

    (@bungeshea)

    Try using the [snippet_test] shortcode in a post or page and see if it is transformed or not.

    Thread Starter rweiss23

    (@rweiss23)

    OK, good test.

    When I added:
    add_shortcode( ‘snippet_test’, function () {
    return ‘Snippets are working’;
    } );

    to functions.php, it worked fine on page: https://staging2.nepta.com/button/

    When I moved it to a snippet, it did not, as you can see on the button page.

    So weird!

    Oscar

    (@kenkepeople)

    Im facing the same issue,
    when i place the code on the functions.php it works, but is not working when i place it on the plugin.

    The code is:

    add_filter( ‘woocommerce_get_price_html’, ‘price_free_zero’, 9999, 2 );

    function price_free_zero( $price, $product ) {
    if ( $product->is_type( ‘variable’ ) ) {
    $prices = $product->get_variation_prices( true );
    $min_price = current( $prices[‘price’] );
    if ( 0 == $min_price ) {
    $max_price = end( $prices[‘price’] );
    $min_reg_price = current( $prices[‘regular_price’] );
    $max_reg_price = end( $prices[‘regular_price’] );
    if ( $min_price !== $max_price ) {
    $price = wc_format_price_range( ‘<span class=”amount”>’ . do_shortcode( ‘[contact-form-7 id=”19909″ title=”Formulario de precios”]’ ) . ‘</span>’, $max_price );
    $price .= $product->get_price_suffix();
    } elseif ( $product->is_on_sale() && $min_reg_price === $max_reg_price ) {
    $price = wc_format_sale_price( wc_price( $max_reg_price ), ‘<span class=”amount”>’ . do_shortcode( ‘[contact-form-7 id=”19909″ title=”Formulario de precios”]’ ) . ‘</span>’ );
    $price .= $product->get_price_suffix();
    } else {
    $price = ‘<span class=”amount”>’ . do_shortcode( ‘[contact-form-7 id=”19909″ title=”Formulario de precios”]’ ) . ‘</span>’;
    }
    }
    } elseif ( 0 == $product->get_price() ) {
    $price = ‘<span class=”amount”>’ . do_shortcode( ‘[contact-form-7 id=”19909″ title=”Formulario de precios”]’ ) . ‘</span>’;
    }
    return $price;
    }

    • This reply was modified 2 years, 6 months ago by Oscar.
    • This reply was modified 2 years, 6 months ago by Oscar.
    • This reply was modified 2 years, 6 months ago by Oscar.
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Snippet not executing’ is closed to new replies.