• Hi,

    I have PHP snippets like this:

    include get_stylesheet_directory() . '/inc/prices.php';
    echo getMoneyUS($us21);

    It shows the price that is listed in prices.php. Having a single snippet on a page works fine. Having a second snippet with the same code, just a different price call, either breaks the page, or it shows $0.00 for the second one. The break happens if I use INCLUDE in both snippets. Using INCLUDE_ONCE or no INCLUDE at all in the second one produces $0.00.
    This code works fine in my static HTML pages.
    Now, seeing $0.00 tells me that my monetary function works fine, but why the code in the snippet does not read the prices.php for the second one, that is something I cannot figure. The variable is there. Plus, the first price is shown correctly.

    Thanks

    • This topic was modified 4 years, 1 month ago by wp800s.
    • This topic was modified 4 years, 1 month ago by wp800s.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Temyk

    (@webtemyk)

    Hello.

    If you use the snippet several times on the same page, you need to use include_once, otherwise there will be errors.
    The rest of the problem is in your code. The snippet only executes the code.

    Thread Starter wp800s

    (@wp800s)

    Thank you. Makes sense. But it is puzzling for me why I get those zeros after first value was presented correctly. Using the same code in my static HTML pages works just fine. :/
    Anyhow, thank you for clarification.

    Plugin Support Temyk

    (@webtemyk)

    I haven’t seen your code, so I can’t tell you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multiple PHP snippets not working’ is closed to new replies.