Bug – PayPal button not showing when product page rendered via shortcode
-
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
- 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)
- Create another page in WordPress and inside the page use the shortcode:
[product_page id="1078"]
And publish the page - 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 linereturn 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.
- The topic ‘Bug – PayPal button not showing when product page rendered via shortcode’ is closed to new replies.