Incorrect value returned by `filter_packages` function when `$package['contents']` is empty
Closed this issue · 3 comments
Bug Description
I'm from IconicWP
In dokan-pro/includes/Shipping/Hooks.php
within filter_packages
function if the $package['contents'] is empty then the function is returning the $package
variable, which is incorrect.
If the filter_packages doesn't have the valid data that it needs to process its functioning then it should return the original variable i.e. $packages instead of $package.
https://shottr.cc/s/UBEG/SCR-20240617-guc.png
Since this manipulates the original shipping packages, this causes severe side effect within our plugin Orderable.
By the looks of it, it looks like this is a typo. We would appreciate if you will fix this issue ASAP.
Step To Reproduce
- Check the source code of
filter_packages
function indokan-pro/includes/Shipping/Hooks.php
- Notice that if
$package['content']
is empty then the function returns $package variable which is just an element within the array.
Expected Behaviour
If $package['contents'] is empty then it should return the original variable i.e. $packages.
Actual Behaviour
If $package['contents'] is empty then it returns the an index from the array.
Additional Information
No response
Environment (please complete the following information)
1. Dokan Version: 3.11.3
2. Dokan Pro Version: 3.11.2
3. WooCommerce Version: 8.9.3
4. Browser: all
5. Current Theme: Store Front
Hi @pramodjodhani (from IconicWP), thank you for reporting this issue and providing such a detailed explanation. You're correct about the bug in the filter_packages
function in dokan-pro/includes/Shipping/Hooks.php
.
I've reviewed the code and confirmed the error where $package
is being returned instead of $packages
when $package['contents']
is empty. This indeed could cause unexpected behavior, especially for plugins like Orderable that interact with the shipping packages.
I've submitted a pull request (PR) to address this issue. The PR includes the following changes:
- The
filter_packages
function now correctly returns$packages
when$package['contents']
is empty.
The PR is currently under review. Once it's approved and merged, the fix will be included in our next release of Dokan Pro.
Thank you again for bringing this to our attention and helping us improve Dokan Pro. If you have any questions about the proposed fix or need any further assistance, please don't hesitate to ask. We'll keep you updated on the status of the PR.
Thank you for confirming and submitting the PR. 🙌
Also, do you have an ETA for when this fix can be released? We have completed the development of our new feature which integrates with Dokan. However we may not be able to release the update until you release this fix.
Hi @pramodjodhani,
Thank you for your follow-up. I'm glad to hear that you've completed the development of your new feature integrating with Dokan.
Regarding the ETA for the fix, I'm pleased to inform you that we have a specific release date planned. The fix will be included in our next release, which is scheduled for July 10th. This is about two weeks from now, which should allow for thorough testing and integration.