plugin updates
This commit is contained in:
@@ -176,6 +176,12 @@ abstract class WC_Abstract_Google_Analytics_JS {
|
||||
* @return array
|
||||
*/
|
||||
public function get_formatted_cart(): array {
|
||||
$cart = WC()->cart;
|
||||
|
||||
if ( is_null( $cart ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return array(
|
||||
'items' => array_map(
|
||||
function ( $item ) {
|
||||
@@ -190,12 +196,12 @@ abstract class WC_Abstract_Google_Analytics_JS {
|
||||
)
|
||||
);
|
||||
},
|
||||
array_values( WC()->cart->get_cart() )
|
||||
array_values( $cart->get_cart() )
|
||||
),
|
||||
'coupons' => WC()->cart->get_coupons(),
|
||||
'coupons' => $cart->get_coupons(),
|
||||
'totals' => array(
|
||||
'currency_code' => get_woocommerce_currency(),
|
||||
'total_price' => $this->get_formatted_price( WC()->cart->get_total( 'edit' ) ),
|
||||
'total_price' => $this->get_formatted_price( $cart->get_total( 'edit' ) ),
|
||||
'currency_minor_unit' => wc_get_price_decimals(),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -58,6 +58,9 @@ class WC_Google_Analytics extends WC_Integration {
|
||||
// utm_nooverride parameter for Google AdWords
|
||||
add_filter( 'woocommerce_get_return_url', array( $this, 'utm_nooverride' ) );
|
||||
|
||||
// Mark extension as compatible with WP Consent API
|
||||
add_filter( 'wp_consent_api_registered_' . plugin_basename( __FILE__ ), '__return_true' );
|
||||
|
||||
// Dequeue the WooCommerce Blocks Google Analytics integration,
|
||||
// not to let it register its `gtag` function so that we could provide a more detailed configuration.
|
||||
add_action(
|
||||
|
||||
@@ -94,7 +94,7 @@ class WC_Google_Gtag_JS extends WC_Abstract_Google_Analytics_JS {
|
||||
function %2$s(){dataLayer.push(arguments);}
|
||||
// Set up default consent state.
|
||||
for ( const mode of %4$s || [] ) {
|
||||
%2$s( "consent", "default", mode );
|
||||
%2$s( "consent", "default", { "wait_for_update": 500, ...mode } );
|
||||
}
|
||||
%2$s("js", new Date());
|
||||
%2$s("set", "developer_id.%3$s", true);
|
||||
|
||||
Reference in New Issue
Block a user