• Resolved gileli121

    (@gileli121)


    Hello,

    I discovered what I think that is some bug with your plugin.

    Because of my development skills, I spent a few hours debugging the PHP code and found exactly what line in your plugin caused this issue so all you need to do is pick my investigation effort and make a bugfix, please ??

    The bug happens when using this plugin via woocommerce shortcode feature (more about it here https://woocommerce.com/document/woocommerce-shortcodes/#product-page )

    Plugin version

    Version 1.0.36

    Steps to reproduce

    1. Create a product with PayPal button enabled (using this plugin). Once created, you have product id. in my case it is 1078 (in the next steps I assume that it is 1078 but you will need to reproduce it with your own generated product id)
    2. Create another page in WordPress and inside the page use the shortcode: [product_page id="1078"] And publish the page
    3. Open the new page.

    Expected Result

    You should see the PayPal button rendered inside the new page

    Actual Result

    You will not see the button rendered

    Investigation result

    In your plugin source code, in the file wp-content/plugins/pymntpl-paypal-woocommerce/src/Utils.php method: get_queried_product_id There is a bug (depends on how you look at it…). All of the code relies on the fact that the method returns the product ID, which is 1078 in my case. However, in this scenario (of using it via shortcode), the product id that returned is wrong, and it is the page id (the id of the test page that hosts the shortcode).

    As a result, the PayPal buttons are not rendered.

    Forcing the method to return 1078 (by putting line return 1078; at start of method) will fix the issue like magic.

    Please fix the method or provide some alternative solution for using the shortcode feature.

    For now is there any better workaround instead of modifying plugin source code? I should not do it and it is bad practice.. I was hopping that by doing it I will find possible idea how to trick it outside.

    Thank you.

    • This topic was modified 1 year, 2 months ago by gileli121.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter gileli121

    (@gileli121)

    I found a way to workaround it outside.

    This is bad workaround but as long as it is from outside then I can live with it.. but please fix it.

    My workaround to trick it was to add this to my custom page template:

    <?php
    /*
     *
     * Template Name: Brizy Product Page
     *
     */
    
    // Workaround for https://www.ads-software.com/support/?post_type=topic&p=17010000
    global $product;
    $product = 1078;
    
    ....
    ....

    Because your method get_queried_product_id is written, it will not override the value $product because it has a condition to set it only when it is undefined. So, my workaround was to define it to 1078 outside. I could do it even from the header file but to make it more isolated, I did it from the custom page template that I use only for the product page (that was made with the brizy page builder plugin and there I put the shortcode)

    Plugin Author Payment Plugins

    (@mrclayton)

    Version 1.0.37 released which resolves this issue.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Bug – PayPal button not showing when product page rendered via shortcode’ is closed to new replies.