'WooCommerce compatibility - using get_id() method with older versions in third party plugins
Does anyone know if it would be possible to add the get_id() method with an older version of WooCommerce in a third party plugin, so it would work with the Google tag manager plugin?
I don't want to update the plugin right now as it would mess up to site.
Anyone know if it's possible?
Thanks
Solution 1:[1]
you can use like this for code compatibility with old version
global $woocommerce;
// if old version of WooCommerce
$product_object = version_compare( $woocommerce->version, '3.0', '<' ) ?
$order_data->get_product_from_item( $item ) : $item->get_product();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ashish |
