Hi Jeremy,
I’ve been using your fantastic WordPress plugin for a while now and it’s been incredibly helpful. However, I’ve recently encountered a PHP error in one of the functions, and I’m seeking your expertise to help resolve it.
The specific function causing the issue is was_match_methods in the file [/public_html/wp-content/plugins/woocommerce-advanced-shipping/includes/class-was-method.php:93]. The error message I’m getting is “CRITICAL Uncaught Error: [] operator not supported for strings.” After reviewing the code, I noticed that $matched_methods is initially declared as an empty string ($matched_methods = ”;), but later in the loop, it’s treated as an array ($matched_methods[] = $method->ID;), resulting in the mentioned error.
To resolve this issue, I suggest initializing $matched_methods as an empty array, like so: $matched_methods = array();. I’ve made this adjustment locally, and it seems to have resolved the error.
Here’s the updated code snippet:
public function was_match_methods( $package ) {
$matched_methods = array(); // Initialize as an array(fixed)
$methods = get_posts( array( 'posts_per_page' => '-1', 'post_type' => 'was', 'orderby' => 'menu_order', 'order' => 'ASC' ) );
foreach ( $methods as $method ) :
$condition_groups = get_post_meta( $method->ID, '_was_shipping_method_conditions', true );
// Check if method conditions match
$match = $this->was_match_conditions( $condition_groups, $package );
// Add match to array
if ( true == $match ) :
$matched_methods[] = $method->ID;
endif;
endforeach;
return $matched_methods;}
I wanted to bring this to your attention, and I’m open to any suggestions or guidance you may have. Your assistance in resolving this matter would be greatly appreciated.
Thank you for your time and for creating such a valuable plugin.
Best regards,
Ethan Reubens
[email protected]
webengine.co.il
The page I need help with: [log in to see the link]
