This commit is contained in:
Mike Jolley 2013-02-14 16:50:45 +00:00
parent 24fff87877
commit 18ab00d10d
2 changed files with 3 additions and 3 deletions

View File

@ -255,7 +255,7 @@ class WC_Google_Analytics extends WC_Integration {
// Add single quotes to allow jQuery to be substituted into _trackEvent parameters // Add single quotes to allow jQuery to be substituted into _trackEvent parameters
$parameters['category'] = "'" . __( 'Products', 'woocommerce' ) . "'"; $parameters['category'] = "'" . __( 'Products', 'woocommerce' ) . "'";
$parameters['action'] = "'" . __( 'Add to cart', 'woocommerce' ) . "'"; $parameters['action'] = "'" . __( 'Add to cart', 'woocommerce' ) . "'";
$parameters['label'] = "'" . ( $product->get_sku() ? __('SKU:', 'woocommerce') . ' ' . $product->get_sku() : "#" . $product->id ) . "'"; $parameters['label'] = "'" . esc_js( $product->get_sku() ? __('SKU:', 'woocommerce') . ' ' . $product->get_sku() : "#" . $product->id ) . "'";
$this->event_tracking_code( $parameters, '.single_add_to_cart_button' ); $this->event_tracking_code( $parameters, '.single_add_to_cart_button' );
} }
@ -275,7 +275,7 @@ class WC_Google_Analytics extends WC_Integration {
// Add single quotes to allow jQuery to be substituted into _trackEvent parameters // Add single quotes to allow jQuery to be substituted into _trackEvent parameters
$parameters['category'] = "'" . __( 'Products', 'woocommerce' ) . "'"; $parameters['category'] = "'" . __( 'Products', 'woocommerce' ) . "'";
$parameters['action'] = "'" . __( 'Add to Cart', 'woocommerce' ) . "'"; $parameters['action'] = "'" . __( 'Add to Cart', 'woocommerce' ) . "'";
$parameters['label'] = "($(this).hasAttr('data-product_sku')) ? ('SKU: ' + $(this).attr('data-product_sku')) : ('#' + $(this).attr('data-product_id))"; // Product SKU or ID $parameters['label'] = "($(this).data('product_sku')) ? ('SKU: ' + $(this).data('product_sku')) : ('#' + $(this).data('product_id'))"; // Product SKU or ID
$this->event_tracking_code( $parameters, '.add_to_cart_button:not(.product_type_variable, .product_type_grouped)' ); $this->event_tracking_code( $parameters, '.add_to_cart_button:not(.product_type_variable, .product_type_grouped)' );
} }

View File

@ -50,7 +50,7 @@ global $product;
break; break;
} }
echo apply_filters( 'woocommerce_loop_add_to_cart_link', sprintf('<a href="%s" rel="nofollow" data-product_id="%s" class="%s button product_type_%s"%s>%s</a>', $link['url'], $product->id, $link['class'], $product->product_type, $product->get_sku() ? ' data-product_sku="' . $product->get_sku() . '"' : '', $link['label'] ), $product, $link ); echo apply_filters( 'woocommerce_loop_add_to_cart_link', sprintf('<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="%s button product_type_%s">%s</a>', esc_url( $link['url'] ), esc_attr( $product->id ), esc_attr( $product->get_sku() ), esc_attr( $link['class'] ), esc_attr( $product->product_type ), esc_html( $link['label'] ) ), $product, $link );
?> ?>