Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions classes/class-wc-connect-api-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ protected function get_settings_values() {
'dimension_unit' => strtolower( get_option( 'woocommerce_dimension_unit' ) ),
'weight_unit' => strtolower( get_option( 'woocommerce_weight_unit' ) ),
'wcs_version' => WC_Connect_Loader::get_wcs_version(),
'wcshipping_version' => WC_Connect_Loader::get_wc_shipping_version(),
Copy link
Contributor

@samnajian samnajian Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's worth checking how currently wcshipping_version is used on connect-server side, I guess in some cases it's used to determine if the request is coming from WC Shipping or not.
Maybe simply passing active_plugins => get_option( 'active_plugins' ) or get_plugins(with a plugin's folder as argument) would be a safer alternative.

Copy link
Contributor Author

@ayushpahwa ayushpahwa Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would actually argue to remove this ambiguous way. We should send the plugin_source key along with the API and if it is defined, that's the one we should be using. What do you think?
CleanShot 2025-08-22 at 20 40 13@2x

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd anyways need the version as well, wcshipping_version currently has 2 use cases:

  • The actual version number of the plugin sending the request.
  • The existence of wcshipping_version, implies request is coming from wcshipping_version
    While the above is not perfect, we shouldn't refactor it at this stage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was not to remove the wcshipping_version but to add a better plugin source check. I worked on a draft over the weekend for this but it needs a lot of test fixes. I have pushed it here and will fix in the cooldown week. Till then I guess both of these PRs can be parked.

'jetpack_version' => 'embed-' . WC_Connect_Jetpack::get_jetpack_connection_package_version(),
'is_atomic' => WC_Connect_Jetpack::is_atomic_site(),
'wc_version' => WC()->version,
Expand Down
17 changes: 17 additions & 0 deletions woocommerce-services.php
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,23 @@ public static function is_wc_shipping_activated() {
return in_array( 'woocommerce-shipping/woocommerce-shipping.php', get_option( 'active_plugins' ) );
}

/**
* Get the version of WooCommerce Shipping plugin
*
* @return string
*/
public static function get_wc_shipping_version() {
if ( ! self::is_wc_shipping_activated() ) {
return 'undefined';
}
// Ensure this code runs within the WordPress admin context or after wp-admin/includes/plugin.php is loaded.
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$all_plugins = get_plugins();
return $all_plugins['woocommerce-shipping/woocommerce-shipping.php']['Version'];
}

/**
* Returns if both Woo Shipping and Woo Tax are active.
*
Expand Down
Loading